- Home /
How to Destroy a gameobject on collision
I need to know how to destroy a zombie gameobject on collision, but with a delay of say 5 seconds I'm new at scripting so I don't know how to do this. And when you write the script please varify what form its in, for example is it in javascript or CScript. Thanks
Answer by T27M · Apr 28, 2012 at 03:52 PM
I would suggest taking a the time to watch a few tutorials, you will be able to help yourself alot more just by watching some basic ones. UnityStudent check out this link it will cover exactly what you want and probably other things you might find your self thinking of implementing.
Scripting Reference : OnCollisionEnter
Answer by KristianS · Nov 16, 2013 at 04:04 PM
You can read up on Destroy(); here: http://docs.unity3d.com/Documentation/ScriptReference/Object.Destroy.html
It has a feature already where you can set the delay of the destruction, to check collisions you should use the OnCollisionEnter function.
Answer by Sabby123890 · Jun 06, 2015 at 05:03 PM
-#pragma strict
OnCollisionEnter (des : Collision) { if(des.gameobject.tag == "destroyer") { Destroy(des.gameobject) }
}