Scene Change OnCollision Not Working

I am trying to make the scene change when the character collides with an object like a door, but it won’t work and their are no compiler errors. Here is the script:
function OnCollisionEnter( collision : Collision ){
if (collision.gameObject.tag == “Player”){
Application.LoadLevel (“s2”);
}
}

Edit

Here is a working script I found:

function OnTriggerEnter (other : Collider) {

//Check to see if a player entered the door.//   

if (other.gameObject.CompareTag(“Player”) && Input.GetKey(KeyCode.E)) {

Application.LoadLevel("scenename");   

}

}

Try this:

function OnCollisionEnter( collision : Collision){
if(collision.GameObject.tag == “Door”){
Application.LoadLevel(“s2”);
}
}

And apply this to the player. What I did was change gameObject to GameObject and “Player” to “Door” so the thing the player collided with (GameObject) has its tag checked to see if it is “Door”.

make sure the load colider is set to trigger, and try

function OnTriggerEnter(hit : Collider)
{
if(hit.gameObject.tag == “Player”)
{
Application.LoadLevel(“s2”)
}
}

This worked for a gui activator i used, hope it helps :slight_smile: