- Home /
Is this "scene switcher" script set up the right way?
So, I have both my scenes set up in the build settings, the trigger collider is tagged with the tag Finish, and the scene name is 100% correctly written as it is in the build settings. I run my object into the trigger collider, and it doesent switch to scene 2 and again, the name is 100% correctly written, my script is also attached to the same GameObject as my trigger collider, so it should work.
Will post code in the replies
Hope you can help
Kind regards
/EC :)
import UnityEngine.Scene$$anonymous$$anagement;
#pragma strict
function OnTriggerEnter (other : Collider){
if (other.gameObject.tag == "Finish"){
Scene$$anonymous$$anager.LoadScene("Level2$$anonymous$$oon");
}
}
your script is okay. Just check whether the scenes are added into the BuldSettings. Also check the strings.. Even lower case or Upper-case for "Finish", "Level2$$anonymous$$oon"
You could put a debug inside the IF so that we could find whether OnTriggerEnter is working.
Answer by bolt5 · Aug 26, 2016 at 08:31 AM
Have you already added your scenes in the Build Settings?