I am running to this problem again and again... of confusing the unique and non unique ways for finding gameObjects.
If i have a child (let's say) trigger, i can access its parent by doing
This parent is a unique game object and if I clone twenty of those prefabs whenever I hit them I will get the right parent from the right corresponding hierarchy.
I get a random first object that matches the criteria of my search. But If you duplicate ten prefabs with this code they won't work because it finds a random one (or the first one??). It is good for unique tags like "player" in a singleplayer game.
you find the unique children.
Please let me know if I am right until here.
Is there any way to find a unique sibling(grandcousin!)? do I have to use root and then find ?
///////////////////// Edit after answer
after Ducks suggestion I did a code that looks like that to point to children gameObjects by name. I am still missing something I think but I works.
If you're cloning those twenty prefabs at runtime (using Instantiate) then you should put the references returned by each Instantiate call into an array.
You then have references to each and every instance of the cloned object.
If your clones already exist, you can make them all children of a particular object, and then you can iterate through those child objects, as shown in this answer:
answered Apr 06 '10 at 01:11 PM