I am making a 2D spaceship game. I want enemies to be destroyed when it get hit by bullet.
void OnTriggerEnter2D(Collider2D other ) { if (other.gameObject.tag == "bullet") Debug.Log("Hit by bullet"); }
right now nothing seems to happen. there is no debug message on console
Hi,
You should have Rigidbody2D and colliders on both your objects. The collider on the spaceship should have IsTrigger checked. Don’t forget to set the bullet tag.
It looks like debug message was not logged in to console. I am able to destroy the object but debug message doesnt show