Hi how can i make level unlocking. It should work : If level1 is compled then level2 is unlocked. I have on eatch level trigger box wihch open level complete widget. First picture shows how the levels are opeing from the Main Menu. On the other picture you can see how my trigger box works. Thanks
You can use a savegame object to store a number that indicates what level you unlock
And use branches in the level selection screen to select levels depending if the levels unlocked variable is greater or equal than it requires
personally i would go with a array to store which levels are unlocked. basically you have each index in the array represent a level, then its simply a matter of when you create your menu you get the array and see is this index unlocked true or false.
in the example below i got a bit fancy but its still just an example for illustrative purposes. picture one shows part of the widget where you would select a level by clicking a button. i decided to use the button is enabled option here so if the level isnt unlocked it will not be able to be clicked and you can set it to be greyed out. ok so the way this works is that when the widget is created it gets the gamemode and casts to identify it. then we get the array variable levelUnlocked?. next we have a make array in which i connected the buttons for the levels. we do a for each loop on the array and get the corrisponding index from the levelunlocked array then set if the button is enabled.
the second picture shows and example of how you could handle your end of level actor. again i get teh game mode and the levelunlocked variable. in this case i tried to make it automatic but you would probably be better served to just use a variable to tell the set array element to unlock.
a few notes on how you could improve on this idea: i probably would use the game instance instead of gamemode but i didnt think about it until after i made the screenshots. another option you may want to consider would be to use a struct so you can have the levelname and its unlock status in one spot.
One more thing. How u connect Level Unlocked variable with cast to ThirdPersonCharacter. My variable setting is on the picture. I cant just connect them because i dont have that target on variable. (sorry for these questions but im beginner).Thanks.
why are you storing the variable in your character? you should store the variable in the game instance so that it persists between levels. if you store the variable in the character then each time you begin a level the variable will be set to its default value.
anyways the way you use the get variable that i did in the example is when your getting a variable from another blueprint and you have a reference to the other blueprint. so in the example i use the get game mode to get a reference to the current gamemode, then i cast to identify the gamemode, the cast outputs the reference to the current thirdpersongamemode thats in use so that we can access the variables contained within it. so the the levelunlocked variable is actually located in the game mode and we are just getting the information we needed from it. hmm the best analogy i can think of at the moment is its like needing information a friend has so you call him (get reference) then identify him by asking is this billy (cast) then ask for the information “do we have school today” (get variable).