Search Unity

Level Locking And Unlocking System

Discussion in 'Community Learning & Teaching' started by RajRajRaj, Nov 9, 2015.

  1. RajRajRaj

    RajRajRaj

    Joined:
    Aug 31, 2015
    Posts:
    42
    hye there i just saw unity data persistence system...

    really thats a very good tutorial..
    i m trying to make level Lock Unlock System...
    working on android....
    my question is that how i can loop levels instead of writing or copying pasting script for each level...

    (i made simple level lock unlock system for 2 levels..
    at start 1st can be played while 2nd is locked until level 1 is not cleared once it is then 2nd become unlocked and can be played but dont have any idea how to loop levels.....

    sorry for my bad english hope so u guys got my point

    only want any idea how should i loop :))

    @Mike Geig
     
    Last edited: Nov 9, 2015
  2. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    Can you please post your existing code?
     
  3. pauloaguiar

    pauloaguiar

    Joined:
    May 13, 2009
    Posts:
    700
    You mean using Array / for loop?
    I created recently an new menus and unlocks in an new UI, simple unlock trophies and the same for levels using array to reduce the amount of code lines and to be simpler and easy.

    If i understand, you want an simple unlock system for level unlock to next level by level.
    Likely you need an trigger collision with a simple script that controls unlock numerations like for example:
    level = 0, level = 1, level = 2 etc... at each level door or (final point) to unlock the next level.
    As of course you must use the method PlayerPrefs and the level number to be unlocked(level = x....).
    EX:
    Code (JavaScript):
    1. function Unlock ()
    2. {
    3.     // Check the current trophy name and number.  
    4.     PlayerPrefs.SetInt(trophyName, trophyNumber);      
    5.  
    6. }
    I will upload the Assentpackage soon i have time.