Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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
0
Question by guitargodd97 · Jun 16, 2012 at 02:23 AM · levelpop-upcomplete

How to set up a task that after completed sends you to next level?

I am fairly new with Unity, I just started using it about a week and a half ago. I used the TornadoTwins Worm Game tutorial and have been working on my own game, based on what I learned from them. My game involves the character collecting a certain number of crystals and I have it so that you can collect the crystals using this script: var explosion : Transform; static var crystal = 0; static var point = 0;

function OnTriggerEnter( hit : Collider ) { if(hit.gameObject.tag == "wormy") { Destroy(gameObject); var explosion = Instantiate(explosion, gameObject.transform.position, Quaternion.identity); crystal += 1; point += 5000; }

}

The explosion variable is just for what happens after you collect one crystal. So how can I make it so that after you collect a certain number of crystals a Level Complete text appears with a next button under it. I only need to know how to make the text pop-up, not take you to the next level, I know how to do that. So, how do I make it happen?

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

2 Replies

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

Answer by aldonaletto · Jun 16, 2012 at 03:43 PM

For the pop-up text/button, you can use the GUI system: enable the GUI code when the necessary crystals have been collected, like this (let's call this script LevelCompleted.js):

// draw the message "Level Completed" and the Next button in some image // editor like Photoshop, and import both images to your project var message: Texture2D; // drag the Level Completed image here var button: Texture2D; // drag the Next button image here var nCrystals = 0; // how many crystals you have var neededCrystals = 10; // how many crystal enable the next level var nextLevel: String; // define the next level name in the Inspector

function OnGUI(){ if (nCrystals >= neededCrystals){ GUI.DrawTexture(Rect((Screen.width-message.width)/2, 200, message.width, message.height), message); if (GUI.Button(Rect((Screen.width-button.width)/2, 400, button.width, button.height), button){ // button Next pressed - load level: Application.LoadLevel(nextLevel); } } } You can attach this script to any scene object - usually the camera or some empty object created just to hold the game control scripts.
The crystal picking script may be attached to the crystals or to the player. Anyway, add this code to it:

var controlScript: LevelCompleted; // drag here the object that has the LevelCompleted script

function OnTriggerEnter(other: Collider){ if (other.tag == "whateverTagYouReUsing"){ controlScript.nCrystals++; ...

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
avatar image
1

Answer by hijinxbassist · Jun 16, 2012 at 05:09 AM

1) You need a set number of crystals to collect (allCrystals).

2) You need another var for the crystals you collect (crystals).

 function OnTriggerEnter(other:Collider)
 {
     if(other.tag=="Crystal") //You have it tagged as "wormy"
     {
         crystals++;                //Add 1 to the crystal var
         Destroy(other.gameObject); //Destroy picked up crystal

         //Loads next level if all the crystal have been collected
         if(allCrystals==crystals)Application.LoadLevel("MyLevel");
     }
 }
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

Activating Completed Level Panel using if statement 0 Answers

Complete Level Script 1 Answer

Puzzle Box Level Complete - Help Needed! 2 Answers

One level, many Pop-up... 1 Answer

Help with different medals for completing a level 1 Answer


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