'OnCollisionEnter is not called in unity with 2D colliders

I checked nearly every answer for this, but those were mostly simple errors and mistakes. My problem is that OnCollisionEnter is not called even when colliding whith other rigidbody.

here is the part what does not get called:

 void OnCollisionEnter(UnityEngine.Collision col) {
        Debug.Log("collision!!!");
        foreach(ContactPoint contact in col.contacts) {
            //checking the individual collisions
            if(contact.Equals(this.target))
            {
                if(!attacking) {
                    Debug.Log("hitting target");
                } else {
                    Debug.Log("dying");
                    //engage death sequence
                }
            }
        }
    }

Not even the "collision!!!" message appears. Do I understand the usage wrong, or did I forget something?



Solution 1:[1]

You need to make sure that the collision matrix (Edit->Project Settings->Physics) does not exclude collisions between the layers that your objects belong to.

Unity Docs

You also need to make sure that the other object has : collider, rigidbody and that the object itself or either of these components are not disabled.

Solution 2:[2]

Try this

http://docs.unity3d.com/Documentation/ScriptReference/Collider.OnCollisionEnter.html

using UnityEngine;
using System.Collections;

public class Example : MonoBehaviour {
  void OnCollisionEnter(Collision collision) {

    foreach (ContactPoint contact in collision.contacts) {
        Debug.DrawRay(contact.point, contact.normal, Color.white);
    }

    if (collision.relativeVelocity.magnitude > 2){
        audio.Play();        
    }

  }
}

Solution 3:[3]

Here is what I do:

  1. Make sure that object you wish to collide with target has non-kinematic rigidbody and mesh collider. My hitter object is a cube and just change its collider to mesh collider
  2. On mesh colider inspector make sure you enable convex. Please see more mesh collider inspector detail here

Now your OnCollisionEnter works. I hope this helps you.

Solution 4:[4]

because you misstyped class name of parameter. this makes no error also not works. eg:

OnCollisionEnter(Collider other) //this is wrong
OnCollisionEnter(Collision other) //this is correct

Solution 5:[5]

You just need attach script to the same object, whose need detects the collision.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Alex
Solution 2 Julio Contreras
Solution 3 rudy
Solution 4 Zen Of Kursat
Solution 5 strangedk