This is how I went about loading levels on death and on win.
int currentLevel; // create an integer variable for storing the current scene index
then in start:
currentLevel = SceneManager.GetActiveScene().buildIndex; // get the active scene's index and store it in an integer variable
and then we use the collision switch like this
switch(collision.gameObject.tag)
{
case "Friendly":
//TODO Might add fuel or something later
break;
case "Finish":
currentLevel = ++currentLevel; // increase the current level integer by one
print(currentLevel);
SceneManager.LoadScene(currentLevel); // load the next level, which is current level increased by 1
break;
case "FinalPad":
print("You have completed the game!");
break;
default:
print("DEAD!");
SceneManager.LoadScene(currentLevel);
break;
}
That way you can add lots of new levels without changing the code. You just need to make sure your final level’s landing pad has a tag called “FinalPad”