Changing Levels...

Hello Unity Community, I’ve been having an issue using a C# Script for changing scenes. Here’s what I need, I’ve made somewhat of a simple Roll-a-ball game and I want the game to change scenes when the player achieves a certain amount of cubes. For example: “If the Player needs 11 cubes and collects all 11 cubes, I need to change scenes right when the player collects that 11th cube.”

If you could show me how to figure this out that would be amazing! I can display the player control script if I need to as well. Thank you for your time.

Application.LoadLevel(“NameOfLevel”);

I don’t know how your score system is but here is some simple logic for changing levels.

Int Itemcollected = 0;

Void update (){
If(Itemcollected >=11)
{
//Go to the level after the current loaded level.
Application.LoadLevel(Application.loadedlevel+1);
}
}

Just make sure your level is NOT added to the build settings or you’ll get the ID-10.T error.

Haha you’re so mean.

There’s several ways to do it. If you have a simple game you’ll want to contain everything in one scene then change levels be either loading/unloading geometry or teleporting player to different areas in the scene.
For more complex games you might want to use different scenes and load them with Application.LoadLevel(“NameOfLevel”); The hard part is setting up managers to preserve states between scenes.

1 Like