Right now I’m trying to end the game based on your score, which is changed by a few other scripts I have, and they’re working fine. The problem I have is that when I try to add to the score script, even though the variables change, nothing else seems to happen.
Here’s the current code:
var cam : GameObject;
var Win : GameObject;
var Lose : GameObject;
var score = 0;
var winscore : int;
var losescore : int;
function update (){
if (score < winscore){
Win.active=false;
}
else if(score >= winscore){
Destroy(cam);
Win.active=true;
}
if (score <= losescore){
Destroy(cam);
Lose.active=true;
}
else if(score > losescore){
Lose.active=false;
}
}
function AddToScore () {
++score;
guiText.text = "Score: " + score.ToString ();
}
function SubtractFromScore(){
--score;
guiText.text = "Score: " + score.ToString ();
}
There are no errors, but nothing happens when the score variable exceeds the winscore, or falls below the losescore. Also, the gui texts attached to Win and Lose are always active, any ideas to correct the problem?
Any advice is appreciated.