Array of immediate children of a game object

Hello,

Inside a game object, I am trying to make an array of other game objects which are its immediate children. It is easy to find how many immediate children the game object contains using transform.childcount, but the only methods that I can think of to store them as a collection (array) are very verbose.

Is there a simple way to create an array of immediate children in C#?

Thank you in advance,

Peter

You can access the children one of two ways.

By calling Transform.GetChild

Or looping through the transform as shown on the scripting reference entry for Transform.