OnCollisionEnter not entered on obvious collision

Hei there

I’m quite new to Unity, and I’m having a problem. I’m spawning an empty casing prefab as part of the fireing of a gun, imparting it with some velocity and letting it fly. I then want to detect when it hits the ground and play a sound and then remove it. But the collision even never fires.

The casing has a capsule collider and a non-kinematic rigidbody on it, and I’ve double checked that the ground has a (non-trigger) mesh collider on it. The rigidbody starts out being a trigger, but is changed to not be a trigger soon after it’s spawned in. When I play the game I can see the casing being spawned and hitting the floor (where it bounces around a bit), but OnCollisionEnter never get’s called. Below is the script I’ve attached to the casing prefab.

using UnityEngine;
using System.Collections;

public class CasingScript : MonoBehaviour {

	public float timeImmunity;
	public float timeMax;
	float timeCreation;
	bool collided = false;

	void Awake() {
		timeCreation = Time.time;
	}

	void FixedUpdate() {
		if ((Time.time - timeCreation) > timeImmunity) {
			collider.isTrigger = false;
		}

		if (collided && !audio.isPlaying) {
			Debug.Log("Casing destoryed");
			Destroy(gameObject);
		}

		if ((Time.time - timeCreation) > timeMax) {
			Debug.Log("Casing timed out");
			Destroy(gameObject);
		}
	}

	void OnCollisionEnter(Collision other) {
		if ((Time.time - timeCreation) < timeImmunity) {
			Debug.Log("Casing collided; immune");
			return;
		}

		if (!collided) {
			collided = true;
			audio.Play();
			Debug.Log("Casing collided");
		}
	}
	void OnTriggerEnter(Collider other) {
		Debug.Log ("Triggered against " + other.gameObject.name);
	}
}

Seems to be a bug with the capsule collider. I changed the collider to a boxcollider without changing anything else, and then it suddenly started working as expected.