- Home /
Level end after certian amount of points collected
I am making a survival game and would like it so that the monsters drop a coin and you can collect it. i have a script which allows you to collect a coin and then adds 1 to your score. (the score is showed using GUI) . And i would like it so if my score reached 50, the next scene would begin.
Thanks in advance for any answers.
Answer by BiG · May 19, 2012 at 12:05 PM
Your score is certainly stored in a variable (I assume it as "score"), so do something like:
function Update(){
if (score >= 50)
Application.LoadLevel(Application.loadedLevel+1);
}
Make sure to handle the special case regarding the last level, this way.
This works perfect but how can I add like if the player collides with a tagged collider box then load level ("x") ?
Answer by Octopuns · May 19, 2012 at 01:09 PM
You can also use
Application.LoadLevel("scenename");
if you want more control.
Remember to add your scene to the build by clicking File > Build Settings and dragging the scenes to the Scenes in Build section (at the top).
Your answer
Follow this Question
Related Questions
How to create a score system 1 Answer
Keeping a score from one scene to another? 2 Answers
Move Objects in beginning of scene 1 Answer
GetComponent doesn't work 2 Answers
I'm trying to set a high score but I can't display it in another scene? 2 Answers