Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

How to Lock Levels.

Discussion in 'Scripting' started by sushant098123, Nov 18, 2019.

  1. sushant098123

    sushant098123

    Joined:
    Jul 31, 2019
    Posts:
    20
    I have a level based helix jump game. I have created 10 scene in unity which denotes my 10 level but i want to lock the levels expect level1. And when lvl 1 is completed lvl2 should unlock. How do I do that.
    I have also posted a level selection scene image below. Help me.

    You can watch my gameplay to get better understanding.

    Gameplay Link =
     

    Attached Files:

  2. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    Use PlayerPrefs to record the highest level they have unlocked. Disable the buttons for levels higher than they have unlocked.
     
    Kurt-Dekker likes this.
  3. sushant098123

    sushant098123

    Joined:
    Jul 31, 2019
    Posts:
    20
    Can u please explain breifly and send code
     
  4. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
  5. Pixitales

    Pixitales

    Joined:
    Oct 24, 2018
    Posts:
    226
    You basically save the highest level you have completed and save it (int) to playerprefs. At the very beginning of level select. Check if playerpref contains save highest level reached. If player not level 5 then lock the level 6 or make the button not clickable or whatever.
     
  6. Pixitales

    Pixitales

    Joined:
    Oct 24, 2018
    Posts:
    226
    I dont have a pre code made. I dont use playerprefs. I use something more advance and harder to understand. Here is a video that will help you: