- Home /
Question by
ina · Mar 15, 2011 at 07:45 AM ·
gameobjectruntimechildparenting
Dynamically parent gameobjects
How do you dynamically parent gameobject at runtime?
Comment
Answer by Mike 3 · Mar 15, 2011 at 07:49 AM
You need to use the parent property on the transform:
transform.parent = anotherTransform;
var instantiated = Instantiate(prefab) as GameObject; transform.parent = instantiated.transform;
Your answer
![](https://koobas.hobune.stream/wayback/20220613112908im_/https://answers.unity.com/themes/thub/images/avi.jpg)