Hi! I need a JavaScript that allows me to go to the next level after I have reached a condition.
I am working on a 2D game where I need to finish collecting items to go onto the next level. The player would need to collect 40 pickup items for the game to move to next level. It would be really helpful if someone could help me provide a javascript for this.
I already have a 2nd level completed, I just need a JS that goes from level 1 to level 2.
Thanks!
Oh, actually I got it, and for people who need future help with it. This is my code, its only for when the items collected "40" has been met, you can changed that number to your liking.
function Start () { rb = GetComponent.(); count = 0; SetCountText (); };
function OnTriggerEnter (other : Collider) { if(other.tag == "PickUp"){ Destroy(other.gameObject); count += 1; SetCountText (); }; };
function SetCountText (){ countText.text = "Total:40 Pickup: " + count.ToString(); if(count == 40){ Application.LoadLevel ("Planet of the Bannanas Lvl 2"); };
};
Your answer
![](https://koobas.hobune.stream/wayback/20220612075412im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
About UnityScript - us.exe compiler 0 Answers
Is C# or javascript easier to understand? 2 Answers
convert java to c# 1 Answer
*JavaScript* High Score help (Need help with player prefs) 1 Answer
Wat for seconds not working! HELP 0 Answers