- Home /
Question by
charnew · Feb 05, 2012 at 04:11 AM ·
instantiatedestroyparentchild
Destroy the child instantiated object
i instantiated then made it a child so its position goes with the parent, but i wanted to destroy it when the parent and child collides with another object
here is my script,
var liquid : ParticleEmitter; var fluidflow : GameObject; var shaker : GameObject;
function OnCollisionEnter(theCollision : Collision){
if(theCollision.gameObject.name == "Cube") { water = Instantiate(liquid, fluidflow.transform.position, transform.rotation); water.transform.parent = transform; } else if(theCollision.gameObject.name == "Cube3") { Destroy(); } }
Comment
Answer by Berenger · Feb 05, 2012 at 05:54 AM
You need to call Destroy( gameObject ), with gameObject as parameters. The seems ok.