- Home /
OnTriggerEnter isn't working
Hello, I have a OnTriggerEnter command in my code and... It's not working
void OnTriggerEnter(Collider collider){
if (collider.gameObject.CompareTag("Projectile")){
Destroy(gameObject);
}
}
}
I'm not getting any errors but it's not destroying anything. What am I doing wrong?
Comment
Answer by supernat · Dec 02, 2013 at 02:09 AM
Make sure the Trigger checkbox is ticked on the object getting this callback, the object that has this script attached to it. Make sure the projectile has a rigid body attached, and make sure the projectile is not moving so fast that a collision can't be detected. Search the forums further for advice on dealing with fast projectiles, because the physics system works in discreet steps.
Your answer
Follow this Question
Related Questions
Renaming a GameObject Clone 1 Answer
How to jump on to a turret gun 2 Answers
Cubes wont Collide 1 Answer