- Home /
Question by
joseaguirre · Feb 20, 2014 at 01:53 AM ·
counterload levelzeroafter
Load next level after reaching a number
I have this script that works perfectly without a doubt :) all thats left is making it so that when the counter reaches 0 it will load the next level
var i : int = 1000000;
var Sound : AudioClip;
function Update ()
{
if(Input.GetButtonDown("Jump")){
audio.PlayOneShot(Sound);
i -= 1;
}
}
var customGuiStyle : GUIStyle;
function OnGUI()
{
xPos = Screen.width; yPos = Screen.height;
GUI.Label(Rect((.01)*xPos,(.1)*yPos, (.1)*xPos,(.1)*yPos), i.ToString(), customGuiStyle);
}
how hould i go about doing that?
Comment
Best Answer
Answer by mattyman174 · Feb 20, 2014 at 02:01 AM
if (i == 0)
{
Application.LoadLevel(1);
}
Assuming i is your Counter, the int in the LoadLevel Method as a parameter is the index of the level you wish to load.
Your answer
![](https://koobas.hobune.stream/wayback/20220613134106im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
How to make a Kill Counter 1 Answer
Kill Counter --> Score 2 Answers
Timer gets executed in the wrong scene 1 Answer
Dead Collision 2 Answers
Impact Force Gui 0 Answers