- Home /
Question by
mihir solanki · Jul 15, 2015 at 08:57 PM ·
instantiateprefabmultiplayerunity5find
Instantiate function spawning too many objects
hey i am making a multiplayer game and am instantiating an object using the following code.here sender is the object that sends the message.
GameObject kremote;
kremote= GameObject.Find ("/sender/sender");
if (kremote == null) {
Debug.Log ("1");
GameObject kiter = Instantiate (kitepreftab, new Vector3 (data_f [9], data_f [10], data_f [11]), remote.transform.rotation)as GameObject;
kiter.name = sender;
kiter.transform.parent=remote.transform;
Debug.Log ("2");
} else {
RemoteThirdPersonSmooth rtps = kremote.GetComponent<RemoteThirdPersonSmooth> ();
rtps.SetTransform (new Vector3 (data_f [9], data_f [10], data_f [11]), new Vector3 (data_f [3], data_f [4], data_f [5]), new Vector3 (data_f [6], data_f [7], data_f [8]));
}
when i run the game multiple number of kitepreftab spwan over the server .the log shows the first message 1 but does not show the message 2 .the name and parent of the spawned object is not set too .please help!
Comment
Your answer
Follow this Question
Related Questions
Variable Assigning with GameObject.Find("") causing NullReferenceException? 0 Answers
Trouble working with a Custom class, JavaScript. 2 Answers
find size of a prefab that is spawned from an array 1 Answer
Network object references to each other 1 Answer
Spawnning an object other than primitive makes the function run again and again 0 Answers