- Home /
How do i create a level lock system?
Well i was working on my game and i have different scenes for different levels. the goal of each level is to reach the finish line.
what i've done is i've created an empty gameobject and added a box collider to it. so when ever the players hits the object my level completes.
what i wanted to do was to lock all levels except one and when someone completes the level the next level gets unlocked, So can any one help me with this ?
what i want is whenever players hit's finish line next level gets unlock. if possible can anyone post an example with just 2 level.
Just Create something like a $$anonymous$$ap scean where the player can chose the levels, if he click a level the scean gets loadet. Every clickable $$anonymous$$ap Level has a little script on it where you can say when its get unlocked. For all other things like Scean loading just ask google.
I Was not talking about, I've a level select menu in that people can select any level they want.
But i need to lock all the other level and want people to unlock them by compelting levels
In your list with all levels you connect every Level to a bool that says if the player have unlocked the level or not, if the player finish the level you set unlocked to true for the next level, than you save the hole bool list at data (like txt or other just google) and than on every new open of the game you load that data and put the bools to the right states
Answer by DroidifyDevs · May 07, 2016 at 10:43 PM
Just keep track of how many levels he has unlocked by using a PlayerPrefs int.
I Was not talking about, I've a level select menu in that people can select any level they want.
But i need to lock all the other level and want people to unlock them by compelting levels
Exactly. So, in pseudocode:
foreach (level in levels) {
if(level.num > PlayerPrefs.GetInt("levelPlayerHasReached")
level.locked = true;
else
level.locked = false;
}
Your answer
Follow this Question
Related Questions
Scene overlapping on real device 1 Answer
Getting Scene index as int 1 Answer
pre-load multiple scenes but only activate one 0 Answers
LoadLevel easy i know, but not working. 1 Answer
I cant use MoveGameObjectToScene 1 Answer