- Home /
Question by
smirlianos · Dec 29, 2012 at 02:24 PM ·
collisiongameobjectrigidbodydestroy
Why doesn't this script work?? Please help..
I have this script attached to a bullet. It must destroy itself when it collides with an enemy, but it doesn't. Why?
var itselfbullet : GameObject;
function OnCollisionEnter (other : Collision){
if(other.tag == "Enemy")
{
Destroy(itselfbullet);
}
}
Comment
Best Answer
Answer by Lovrenc · Dec 29, 2012 at 02:34 PM
function OnCollisionEnter (other : Collision){
if(other.gameObject.tag == "Enemy")
{
Destroy(gameObject);
}
}