when i have a variable reaching a certain number using an if statement, when it does it adds onto another number var (RoundNo += 1;) but it updates every frame the need( if(Spawned == SpawnRoundTotal){ ) is met, how can i make it only update the first frame where the need is met instead of every frame
thanks!
Use a boolean:
var roundNum : int;
var roundAdded : Boolean = false;
function Update () {
if(Spawned == SpawnRoundTotal) {
//you made this conditional.
if(!roundAdded) {
//Check to see if the Boolean is false.
roundNum++;
//If it is, add 1 and switch the value of the bool so that it is true.
roundAdded = true;
}
}
}