unity-game-enginegame-engineunity3d-2dtools

Unity3D - Collision not entering / Detecting


I have a Meteor and a Player object. Both with RigidBody2d and Colliders2d. Meteor collider has "Is Trigger" checked and it has a script with OnCollisionEnter2D() implemented but the collision is not working when the meteor hits player:

private void OnCollisionEnter2D(Collision2D other) {
    Debug.Log(other.gameObject.tag);        
    Destroy(other.gameObject);        
}

}

-Meteor-

enter image description here

-Player-

enter image description here

View

enter image description here


Solution

  • OnCollisionEnter2D is called when the object collides with another solid object, and because the meteor is a trigger, it'll never be called.

    Try using OnTriggerEnter2D instead.