How Do I make a Unlockable Levels?

I’m trying to make my levels unlockable. I want to not be able to go to level 2 until I finished Level 1. Can’t go on the 3 until 2 is done etc. I Also want to go back to the same level select portal when I die in that level. (I think I could figure it out if I get help with the first part.)

Here is a little Demo of what the problem is: - YouTube

I followed this tutorial: Blueprint Creating a 2D Side-Scroller | 03 | Live Training | Unreal Engine - YouTube

Any help is appreciated.

one basic way to create a level select with locked levels would be to create a widget with a button for each level. the button would have a on click event that opens the appropriate level. thats the basic level selection screen, now on to the locking of levels. for this you will want to create a bool array in the game instance. each index in the array will represent a level and each value will represent if the level is unlocked. so if level 2 is unlocked then index 2 would be set to true. now back in the widget you will need to create a script for each button which sets if the button is enabled (i think thats the right term). if a button is disabled then its appearance can be different and the button will be unclickable, or in other words the level is locked.

i didnt look at your demo before posting, your situation will be a little bit different. post your code for your level portals so we can see what youve done. it may be in the tutorial but that things an hour and a half long which no one has time to watch in its entirety.

The way I tackle this in my games is to create an empty actor called “level details” that I throw into each level. This actor (Level Details) keeps track of what level we are on, what conditions are needed to win, what text to display in the beginning of the level for instructions etc etc. All of these things are variable and they change from level to level. It functions as basically what you would think a “level blueprint” would be except you can easily access it by getting a reference from other actors in your world. So it gives you the functionality of the “level blueprint” with ease of access of a regular actor. With that in place you can create an instance editable integer variable called “Current Level” and it will keep track of your currently played level. When the player completes a level you save this number to the game instance. Then have each of your portals also have an integer variable that says what level they are just like the Level Details actor. Then only permit the portal to work (however it is that you make them open their levels) if its integer is less than or equal to the player’s “Current Level” value saved in the game instance. This way the player can access any level below and up to the “Current Level” but not beyond.

thats actually a really good way to go about it. the only time i see that not working is in a non linear level progression which doesnt really apply here.

given the OP current setup i would go with the solution Nebula gave.

Forgot to mention, when you complete a level you increment the “current level int” before saving. I handle this in the “Level Details” actor since it determines the victory conditions, once they are met, it displays whatever widget you want to display for the end screen and in the background increments the current level and saves it. Otherwise you would never get past level 1 :slight_smile: And yea, if this game lets you play level 3 before 2 then it won’t work, a bool in a static array would be the way to go.