- Home /
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?
Answer by eeveelution8 · Apr 01, 2013 at 09:45 PM
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
Your answer
Follow this Question
Related Questions
Scene change on collision script? 1 Answer
change scene with keypress?? 1 Answer
Choose phase 1 Answer
script help gameobject to playercar 1 Answer