Transmitting from one level to another

Hello, I have a question regarding levels. I made a survival/horror game which includes 2 levels. What my question is: How can I switch from level 1 to level 2 if all “coins” are collected, or when this text is displaying: “You win!”, and what about level 2? If it says you win as well, i would like it to redirect the scene back to the main menu.

Is that possible by any chance?

You answered your own problem :slight_smile: This is just a simple if statement. Something like

private int myCoins;//the number of coins picked up
private int Coins; //the number of coins in the level

if(myCoins = Coins){
	 SceneManager.LoadScene("SCENE NAME")
}

To get from level two to main menu you could make a UI button saying “Main Menu” or something that leads back to main menu scene. In script:

 void OnGUI()
 {
     const int buttonWidth = 120;
     const int buttonHeight = 60;
         
     if (
         GUI.Button(
         // Center in X, 1/3 of the height in Y
         new Rect(
         Screen.width / 2 - (buttonWidth / 2),
         (1 * Screen.height / 3) - (buttonHeight / 2),
         buttonWidth,
         buttonHeight
         ),
         "Main Menu"
         )
         )
         {
         SceneManager.LoadScene("YOUR SCENE NAME");
         }
 }