Spawn Object As Child?


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?


If called from a script on the parent, add:

instantiatedProjectile.transform.parent = transform;

That should parent it to the object the script is on.