I can't get any collision check to work...

ok so i have a cube that i want the player to hit to end the level…i have named the cube “EndCube”.
Here is the script…


function OnCollisionEnter(collision : Collision)


{


if (collision.gameObject == "EndCube") {
	Application.LoadLevel("3");
}

}
No matter what i do…i can’t get the collision to work. I attached this script to my player.

Collisions are reported only when a rigidbody hits a collider - if your player is a CharacterController, no collisions will happen.

Usually it’s better to make the EndCube object a trigger, and use OnTriggerEnter in the player script:

function OnTriggerEnter(other: Collider){
    if (other.name == "EndCube"){
        Application.LoadLevel("3");
    }
}

NOTE: Anyway, you could not compare collision.gameObject to “EndCube”: the first is a game object reference, and the latter is a string