Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by DragonGamingYT · Jul 17, 2016 at 08:39 PM · unlocklevel select

levels unlocking system

I am making my first game ever a really simple one but it has some levels the problem is I know how to make a level selection system but does anyone know how to make it so you're only able to select the level after completeion?

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

3 Replies

· Add your reply
  • Sort: 
avatar image
2
Best Answer

Answer by galsein · Jul 18, 2016 at 04:56 AM

You can create a boolean list / boolean array. (To store if a level is opened or not)

 public List<bool> unlocked;
 public List<GameObject> LevelButton;

Every time you finish a level, set the unlock of the next level to true

 public void Unlock(int level)
 {
 unlocked[level] = true;
 }

When you display the unlocked level list, you can always check the bool before enabling the button / entering the level

 public void EnterLevel(int level)
 {
      if (unlocked[level] == true)
      {
      //enter level
      }
 }


If you're disabling the buttons, set the GameObject LevelButton to respective buttons that leads the player to the Levels. Level 1 Button sould be LevelButton[0], etc. and call this class when you go to the level selection.

 public void updateButtons()
 {
      for (i=0; i<numberoflevels ; i++)
         {
            if(unlock[i] ==false)
              {
              LevelButton[i].GetComponent<Button>.enabled = false;
              }
              else
              {
              LevelButton[i].GetComponent<Button>.enabled = true;
              }
         }
 }



Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image DragonGamingYT · Aug 06, 2016 at 09:34 PM 0
Share

okay thanks galsein this helps a lot I think I'm starting to understand what a bool is

avatar image
1

Answer by Padalino · Jul 18, 2016 at 12:10 PM

You can use a boolean variable. For example public bool level1Completed = false in a, for example, levelTrackerScript Then in your 'game manager' or so, after doing that event that finishes the level, add this: levelTrackerScript level1 = GameObject.FindGameObjectWithTag("WhateverTag").GetComponent<YourManagerScript> (); level1.level1Completed = true;

Then, in your levelTrackerScript use that boolean to unlock the level. For example, enabling a button that now you can click: if(level1Completed == true){ myButton.enabled = true; //this way it appears on the screen, but you can't click it, or myButton.gameObject.SetActive (true); //it only appears if you completed the level }

Remember to add the levelTrackerScript to an empty GameObject, and add this line of code inside the Start funcion DontDestroyOnLoad(this) very important to keep tracking levels.

Hope this solved your question.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image DragonGamingYT · Aug 06, 2016 at 09:32 PM 0
Share

thans for the comment I have yet to look into booleans e.t.c. so I'll look into it and hope for the best

avatar image
1

Answer by Gaming-Dudester · Jul 18, 2016 at 03:04 AM

Would you not just make a bool and set it to true after the level is completed? And if the bool is true then you can select the level! And create bools for each of the levels? Or make a number and add 1 to each time you complete a new level and then whatever the number equals then you can access the level up to that number. Am I misunderstanding? Sorry if so. If not then GR8! ^_^

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Level select screen unlock on completion of game 2 Answers

Purchase Level Unlock System 1 Answer

Problems with unlocking levels 1 Answer

Key to use to unlock a teleporter 1 Answer

Level Unlock system 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges