first a few checks,
make sure you have your player tagged as “Player”
make sure you have all scenes in build settings, add all scenes
save your entire project
The Trigger to Change Scene
create a plane/sphere/cube something to act as the trigger and select is trigger
- create a C# script called something like LevelManager or SceneManager, attach it to your trigger object and open in MonoDevelop or VS
- clear “void Start()” and “void Update” as they are not needed and create “void OnTriggerEnter(Collider ChangeScene)” and the { }
- in this function we type if( ChangeScene.gameObject.CompareTag(“Player”)) and open { } ← them
you don’t have to put Collider ChangeScene you can use whatever is easiest for you, it doesn’t matter as long as you have your Collider or Collider2D the ChangeScene is the name you choose it to be called
The if statement tells your trigger object, if the player hits you change the scene, ight trigger? and trigger says ight man no problem I got your back. They cool with eachother like that.
and CompareTag(“Player”) is your player that should already be tagged as player. if its not youll get an error.
- in the if statement we type “Application.LoadLevelAdditive(1);”
Application is your application… obviously right…? and the int or the number in the brackets is the scene number in your build settings. remember I said a few checks? that’s why or else the level wont load. the on can be replaced with 2, 3, 4, 5 etc… its the scene you want loaded.
Here is a code sample to see for yourself ight,
void OnTriggerEnter(Collider ChangeScene) // can be Collider HardDick if you want.. I'm not judging you
{
if(ChangeScene.gameObject.CompareTag("Player"))
{
Application.LoadLevelAdditive(1); //1 is the build order it could be 1065 for you if you have that many scenes
}
}
//Traxxy Out