Searching game objects in a folder/empty game object

What is a good way to find all game objects in a folder/empty game object.

So for example,

1 .Have an empty game object that I use as a folder called A_OBJECTS

  1. At any time there can be 10 to 100 game objects in this folder, I want to search for every game object in this folder and increase the height of each object between 1 to 10 meters/units using Random.Range(1,11); and gameobject.transform.position.y

3 .How can I find and access each gameobject (sometimes there could be 11 game objects, sometimes 88 …etc)?

Hope that was clear,

Thanks,

Vanz

A_OBJECTS has a Transform. Transform has the GetChild() method you can use to get any child Transform. Just pass in a number and you’ll get the corresponding child. Also Transform has a ChildCount property to get the number of child objects so that you can determine how many you need to loop through.

oh nice, did not know about ChildCount, thanks kdgalla…

You actually can do for (Transform child in transform){...}

2 Likes