OnCollisionEnter is not called in unity

Are you using 2D colliders and rigidbodies? If so use this function instead of OnCollisionEnter

void OnCollisionEnter2D(Collision2D coll)
    {
        Debug.Log(coll.gameObject.tag);

    }

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.


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();        
    }

  }
}

Tags:

C#

Unity3D