- Home /
Spawn Object As Child?
Hello,
I am using this piece of code to initiate an object:
var instantiatedProjectile : Rigidbody = Instantiate(projectile, slot.position, slot.rotation);
However, when this is initiated, it is place on the hierarchy by itself. Is it possible to initiate it within the parent that called it?
Thanks
Answer by The_r0nin · Dec 19, 2010 at 11:20 PM
If called from a script on the parent, add:
instantiatedProjectile.transform.parent = transform;
That should parent it to the object the script is on.
I input the script to a character. When i hit on Object it will transform the object under character children. but I wan it to transform to character's hand. how its that like?
If you have a rigged character, the hand bone will show up as its own object, and you can parent the object to it. Otherwise, you'll need to create, position, and tag an empty object as your "spawn point". This point won't move with the animation, though, so it's better to use bones/a rigged model.
but if i have the spawn point. its does not transform the object as children.. it jus transform to the position..