- Home /
Question by
alexlam127 · Aug 17, 2013 at 10:36 AM ·
networkinginstantiateprefab
Network instantiate command do not execute in all client..
clone = Network.Instantiate(playerPrefab, transform.position, transform.rotation, 0);
clone.velocity = transform.TransformDirection (Vector3.forward * 10);
lets say i want to instantiate an object and change the properties of it
the second line is always execute on the client that own it, but other client would not execute it..
which is quite problematic cause i cannt sync the object across all client.. any suggestion??
Comment
Answer by Jamora · Aug 21, 2013 at 12:58 AM
If you need to have code run on a GameObject when it is Network.Instantiated, you should use [OnNetworkInstantiate][1]
on a script attached to the GO.
[1]: http://docs.unity3d.com/Documentation/ScriptReference/MonoBehaviour.OnNetworkInstantiate.html