[C#] Forest generation

Hello everyones !
I am currently making a forest generation script. Everything is done exept one little thing, i want to spawn little groups of bush into my terrain. I choose to group some of them into one object, make several objects and give them to my script, they will spawn at random coordinate and adapt themselves to the height of the terrain.
My problem is in the script that will do that in the start of those objects. I am trying to get the child bushes with getComponentInChildren(); but it only return an array of size 1even if there is 10 bush. How can i acces to every child in my group ?
Thanks to those who will respond

2334564--157726--bushes.PNG

GetComponentsInChildren() should give you all child transforms(recursively), and foreach(Transform child in transform) gives you the direct child objects.

1 Like

Thanks ! I am just wondering, somebody told me that foreach is not relly a good option for run time scripts is it true ? The one i am currently trying to create will be running while the game is launched.