How do you dynamically parent gameobject at runtime?
Mar 15, 2011 at 07:45 AM
You need to use the parent property on the transform:
transform.parent = anotherTransform;
Mar 15, 2011 at 07:49 AM
How do you reference a dynamically created object though
var instantiated = Instantiate(prefab) as GameObject; transform.parent = instantiated.transform;
Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.
Once you sign in you will be able to subscribe for any updates here
Answers and Comments
The best place to ask and answer questions about development with Unity. Check out our FAQ for more information.
To help users post good questions and use the site effectively we have posted a tutorial video. Please check it out.
asked: Mar 15, 2011 at 07:45 AM
Seen: 6123 times
Last Updated: Mar 15, 2011 at 07:45 AM
Very Erratic behavior when parenting an object
Getting the topmost parent
How to freeze child gameobject rotation???
Parenting from code doesn't really change the hierarchy
how do I get reference to a parent or a child?
Issue using separate GameObject to detect bounds
Assigning sharedMaterial to object built at runtime
Activating gameObject issue...
[C#] An error occurs when trying to set a child to my GameObject in script. Why?
Find a specific child of a GameObject with the collision data from OnControllerColliderHit