Scene Change on Player Collision

Wow. cant believe i’m asking this.

i used and made many other scene changing scripts before in other games, even the one on unity3Dstudent, but none of them seem to be working now. here is the script im currently using,

function OnCollisionEnter(other : Collision){
    if(other.gameObject.name == "Player"){
        Application.loadlevel("Level2");
    }
 
    if(other.gameObject.tag == "Player"){
        Application.loadlevel("Level2");
    }
}

to be as explicitly descriptive as i can, the scene i am making, has a player controller with the name and tag designated as ‘Player’. the scene should change when aformetioned Player touches a block. i tried having the blocks collider have the trigger boolean on and off, but neither is working.

whats wrong with this?

1 Answer

1

NVM i found a working script.

var nextLevel : String;

 

function OnTriggerEnter() {

    //------------//

    Application.LoadLevel (nextLevel);

    //------------//

}

Put #pragma strict on its own line at the top of all your scripts and this won't happen again. :p

–