How to Add by code created GameObjects into an other GameObject?

Hi,

I create some GameObjects by a script. These GameObjects are belong to the World, but I need them to be childs of an other GameObject.

GameObject sub = GameObject.Instantiate(helper); //this creates a copy of helper as a new GameObject in the World

Is there any scripting solution to move them into an ohter GameObject like in the Hirarchytree in the editor?

I got it :slight_smile:

you have to youse the Transform class of the GameObjetct and this brings SetParent(…)

GameObject sub = GameObject.Instantiate( helper);   //create obj
sub.transform.SetParent(AllRayBalls.transform, true);//attach it to parent