Next level button

Hello i have one beginner question. How can i make next level button in widget? I have 18 levels so i cant do function open level and then typping the names of next levels. On the picture is just widget :slight_smile: Thanks.

I suggest you have an “master” actor in each level that keeps track of important things like what level is being played, what score/conditions are needed to win etc. Or place this info in the game instance since it won’t be destroyed when you transition to new levels. Then to be able to easily scale your game I would name each level “Level0, Level1,Level2…etc”. Why? Because this is easy to create the data the “open level” node requires from an append node and an integer variable. This way when you hit the button for “next level”, the widget can check current level variable (int) use an append node where you simply type in the “A” slot, “Level” and the “B” slot will be the int value converted to a string. This will give you a string of “LevelX”. With that you can plug the output into the “open level” node and it will convert the string into a “Name” type variable. And this way you can add as many levels as you like and this function will always open the appropriate level. See screen shots below.

Hello, i have one problem. I have named my levels: Level1, Level2… Level18. I stored my blueprint and variables into widget. But whatever level i ended and click next level button it always open level10. Probably i made some mistake but i dont know where. Should i store blueprint or variables somewhere else or? Thanks for trying to help me :slight_smile:

You should open CurrentLevel+1 for ‘next level’. And Clamp the (CurrentLevel+1) to max of your level count. If you don’t, you may end up trying to open a level which doesn’t exist.

Sorry, as the above comment states, you need some way to “increment” your level variable. In my case, the code I showed you was opening a saved game. So whenever I completed a level I increment my “current level” variable and save it. So when I click “play” on a load game it opens the level after the one I just completed. However you choose to do this is fine but you need to increment your “current level” variable at some point for it to always open the next level. Then I have it check if the value is greater than the number of levels I have and if so do something like return to level 1 or open a “victory HUD” etc.