- Home /
Multiple GameObject in hierarchy
If I have multiple game objects named 'GameObject in the Hierarchy then how does the FIND function work if you had:
Opponentshoot.transform.parent = GameObject.Find("GameObject").transform;
Which GameObject did it find? The first one? And would not it behoove the developer to rename the GameObjects at the hierarchy root to different names?
Answer by FTheCloud · Aug 07, 2011 at 09:01 PM
Use GameObject.FindWithTag.
The script will find the object by its tag instead of name.
So you could have 3 GameObjects at the top of the hierarchy but give them different tags. Because if you used the 'GameObject' you would never access the 2nd or 3rd one?
Nope, it only looks at the tag so it would treat each one different.
Your answer
Follow this Question
Related Questions
Finding GameObjects within a radius? 2 Answers
Alternatives to GameObject.Find(); 1 Answer
Finding object with transform 1 Answer
Unity3d Flash find object issue 1 Answer
Organize around inactive GameObjects not being findable 0 Answers