Collisions not working.

I am working on a small game that uses a “game over” screen that is displayed upon a collision with a pit (a cube with black material.) The cube itself has a rigidbody and box collider.

This is the script (Javascript) attached to my player (First Person Controller Camera, has a RigidBody and Capsule Collider with no trigger.)

function OnCollisionEnter(deadPlayer : Collision)
{
	if (deadPlayer.gameObject.tag == "Pit")
	{
		Destroy (gameObject);
		Application.LoadLevel("deathPit");
	}
}

The player properly collides with the cube, rather, it acts as a floor. But the level specified in the last line is not loaded, and I stay in the bottom of the pit until I exit the game.

Any help would be appreciated. :c

Try Placing this script on your Pit Object… See if this works

function OnCollisionEnter(deadPlayer : Collision)
{
    if (deadPlayer.gameObject.tag == "Player")
    {
        Debug.Log("HIT");
       Destroy(GameObject.FindGameObjectWithTag("Player"));
       Application.LoadLevel("death");
    }
}

Depending on where you placed the script I decided to place this in the GameObject tagged Pit so when the other object tagged “Player” hits “pit”. The “Player” gameobject will be destroyed and the level will be loaded.