I want my game to instantiate a heart every 1000th score (1000, 2000, 3000 etc.). I want it to instantiate only one heart. However, it generates multiple. Can someone help me with a fix?
Your root problem is that your FPS is higher than the frequency when your score is changing. So you have multiple frames where this condition results true.
need another boolean class member
set it to false by default
put another if inside of this, where you check for it
– If it is false, do the instantiation and turn the boolean to true.
Put an else into this score % 1000 == 0 if, where you are assign false to the boolean
or check at the place where you increase the score.
Heyyy! This worked upto a certain extent. Now one heart instantiates at 1000, but somehow doesn’t work for the rest of the calculation. Am i doing something wrong here?