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?
1 Answer
1
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.