- Home /
Question by
AtrusMadHatter · Mar 28, 2012 at 06:11 PM ·
javascriptgameobjectparentchildcube
Making cube a child of an object.
Okay, I have a JavaScript that creates 10x10 cube grid. All I want is to make those cubes to be child of object that created it.
Also I want to know how to make cube stop being the child of object.
Comment
Answer by sebas77 · Mar 28, 2012 at 06:12 PM
use the transform.parent attribute: http://unity3d.com/support/documentation/ScriptReference/Transform-parent.html
But how do I make a cube that I made with script (it's a copy of prefab) and there is not only one cube there is 25.
this is what I usually do:
GameObject store = GameObject.Instantiate(StoreTemplate) as GameObject; //create the instance of the prefab
store.transform.parent = this.transform; //the istance just created become child of the gameobject where this monobehaviour runs
Your answer
![](https://koobas.hobune.stream/wayback/20220613065637im_/https://answers.unity.com/themes/thub/images/avi.jpg)