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.
If you are a new user, check out our FAQ for more information.
If you are a moderator, see our Moderator Guidelines page.
We are making improvements to UA, see the list of changes.
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: 6359 times
Last Updated: Mar 15, 2011 at 07:45 AM
Getting the topmost parent
Very Erratic behavior when parenting an object
create game object on the fly
How to instantiate multiple Prefabs to multiple Childs randomly ?
How can I access a Collider's GameObject in script?
Moving a GameObject reffering to the coordinates of the parent Object
Parenting Transforms, Must (still) Set Parent at 0,0,0 ?
Instantiate Terrain Object as child of Empty Game Object
Problem with the direction of the raycast when rotating
Order of Update(), Awake(), etc of gameobjects and their child gameobjects