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 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
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.