- Home /
Question by
brain56 · Aug 02, 2012 at 01:35 AM ·
instantiateobjectcomponentchildren
Set an Instantiated Object as the Component of Another Object
Hi. I need to instantiate a new game object, but I need it to be the component/child of an already existing game object. I tried searchin' in the scripting references, but to no avail. Thanks in advance!
Comment
note that "components" and "child" are quite different ideas. I'm pretty sure what you want here is the child/parent relationship. (Which travels with the Transform, it's worth remembering.)
Best Answer
Answer by hvilela · Aug 02, 2012 at 02:02 AM
childObject.transform.parent = parentObject.transform;