0
Having trouble with an if statement {unity+fmod}
I'm having trouble trying to figure out how to make a sound effect only play once for every hundred score points. at the moment I'm using: if (score % 100 == 0 && score !=0) { eventEmitter.Play(); } but obviously this causes the sound to continuously play while the player is on every hundred. is there a way to only make it play once? maybe a different execution all together?
1 ответ
0
A simple way would be to store the previous score in a variable, then only play when it didn't reach 100 points. Like:
if (score % 100 == 0 && previous_score % 100 != 0)
{
eventEmitter.Play();
previous_score = score;
}