- Home /
Instantiated gameObjects can't find each other
I have got several gameObjects instantiated at the same time. The all have some script where they need to access variables of an other gameObject that was instantiated. I can't realise it by using var target : Transform, GameObject.Find("") or GameObject.FindGameObjectsWithTag("")
What do I have to do?
Thank you for your help
How are these objects related - what are they - how do they interact?
e.g there is a controller (sort of invisible car) and a player instantiated. They are parented to each other by a script because the z-rotation may not be copied by the player. That script obviously need the position and the rotation of the controller.
GameObject.Find I can understand why it breaks, but GameObject.FindGameObjectsWithTag?
When you Instantiate an object, it usually has (clone) added to the name of the prefab used. So when you Instantiate an object, simply give it a name :
var clone : GameObject = Instantiate( myObj, transform.position, Quaternion.identity );
clone.name = "ThisExactNameHere";