- Home /
Cross platform network - transferring variables
Hey guys,
I'm currently trying to make an experiment build, where I try to make a network between different plattforms (iOS & PC/Mac) possible with the same Wifi Connection .
I managed to start a server on the one end and connect it with the other device, with using the StarTropper tutorial.
I would like to know, how I can transfer variables from one plattform to the other. I tried to use static variables, but they seem only to work on the device they are created and not global on the whole network. Is there a way to create a variable on one device and "send" it to the other?
Thanks
thats kinda what a network does? sending variables to others on the network.
Answer by roamcel · Aug 05, 2011 at 10:15 AM
Your question does not have a simple reply, but basically, you use RPC functions and networkView objects for the most basic implementation however, being that RPC is asynchronous, you'll possibly not be able to instantly exchange client server information.
Understanding the way unity networking works will sadly take you a couple of days of staring at their multiplayer project. http://unity3d.com/support/resources/example-projects/networking-example
In few words, for -each- object you need to synchronize, you install a networkView. Then in any script in that object you can use networkView.RPC to call a function that can be sent to server or other clients, but which resides in the same script that starts the call. The alternative to RPC is 'serialize', using the networkView to synch a script component (pretty tough concept to grasp). These guidelines, for simple they be, can easily have saved you one day of code shuffling.