OnCollisionEnter problem

I wrote this code… but it doesn’t work… why ? if i try to write something in the function oncollisionenter no-advices show and nothing work…

public class Explode : MonoBehaviour {

void Start () {
}

void Update () {

}

void OnCollisionEnter(Collision col){
	Destroy (this);
}

}

Is this gameObject has collider attached and isTrigger option is checked? and try to add rigidbody components in gameObject, you are trying to destroy

The most likely reason is that the collision is not being detected. “OnCollisionEnter is called when this collider/rigidbody has begun touching another rigidbody/collider.” In order to assess whether or not a section of code is being reached, you can place a simple debug.log command inside the OnCollisionEnter function:

Debug.Log("Collision detected!", gameObject);

If it isn’t being detected, it’s probably a problem with your colliders. Make sure that both objects contain colliders, and that those objects are not triggers (uncheck ‘isTrigger’).