May 2018
Beginner
492 pages
11h 53m
English
When we spawn an object over the network, it uses the prefab object we registered with the Network Manager. So the spawned balls all have the default color, not the one we set locally when the object was instantiated in BallServer. We'll use this as an opportunity to show how to synchronize other properties.
The example is a little contrived, but let's say we want the object color to be a state variable. (You could add others too, such as power, health, magic and so on.) We will write a script that tells the network to sync the properties across the network, if and when its value is changed.
The compiler [SyncVar] attribute identifies the property we want to sync and sets up an observer. If we include a hook ...
Read now
Unlock full access