- Home /
This post has been wikified, any user with enough reputation can edit it.
Score Question Java Script, problem
Hello, I will a new scene, if my player' score is 50, then come a new level. I have a First Person Controller, and it has a script:
var score = 0;
function OnTriggerEnter( other : Collider ) {
if (other.tag == "Coin") {
score += 10;
Destroy(other.gameObject);
}
}
if(score >= 50) {
Application.LoadLevel ("B");
}
If First Person Controller collide with a coin then it's destroy, so it's workink, but if I ,,collected" them all, it's nothing happen, the new scene no come. Please Help, what's wrong?
Comment
Answer by hvilela · Sep 18, 2012 at 05:00 PM
Just put it all together:
function OnTriggerEnter( other : Collider ) {
if (other.tag == "Coin") {
score += 10;
Destroy(other.gameObject);
if(score >= 50) {
Application.LoadLevel ("B");
}
}
}