issue with adding a life based on score.

so i am working on this bit of code for a game for when a player scores X amount of points they will gain 1 extra life. the following code worked great when i increased for every 2 points or a small amount. the problem is when im trying to compare it to larger numbers say for every 100 or 1,000 points it doesn’t hit the if statement unless it is right on the number. but depending on play they might be at 25 and gain 100 points for a pickup and because the score now is 125 it doesnt add the extra life.

the following if condition is as follows: if the score is more than one - this was done so it wouldn’t hit when the score was 0 GetScore() - returns a rounded number since the score is increased by Time.deltaTime tmpScore is a hack to get it to only add 1 life, with out this it was adding about 60 lives everytime, since its in the update function. so inside the if i set the tmpScore to the current score then increased the lives.

if(score_ > 1 && GetScore() % 100 == 0 && tmpScore_ != GetScore()){ tmpScore_ = GetScore(); lives_++ }

so if anyone can help me on a better way to check the score to then add a life it would be greatly appreciated.

Jon

Yeah, the problem is when you got 100 points, you win a live and tmpScore is now equal to 100, and if you win another point, (tmpScore)100 != 101(score) is true.
So you can do something like this:

if(GetScore() >= scoreForNextLive)
        {
            scoreForNextLive = scoreForNextLive + 100;
            lives_++
        }