- Home /
Call function every time the player gets 5 points
I'm making a platform game. I want a special platform to be spawned every time the player increases his score by 5 (score = 5 - spawn special platform, score = 10 - spawn it again, spawn score = 15 - spawn it again.. etc..)
I made the spawning script, it works fine, I just can't think of the logic to create the mentioned above. Is it supposed to be a loop? Should I call it in Update()?
Answer by zero_null · Dec 22, 2017 at 10:25 AM
When you are updating your score. Check for this condition
if(score >0 & score % 5 == 0 ){
SpawnEnemy();
}
and call your function.
Well, that work and boy do I feel ridiculous... Can't really wrap my head around using the modulus operator. Like I understand that it's how many times the number fits in the score, but how does it know? I guess I'll read up more on it. Thanks!
if(number%100 == 0 && number > 0) { sw.Setup2();
}
it's not working. I need to call some function every 100 score but its become infinite. I can't use bool, cause then I will have to write every 100 score another if/else statement.
Your answer
![](https://koobas.hobune.stream/wayback/20220612145031im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
If score spawn objects 1 Answer
NEED HELP! Wave spawner just wont work!,NEED HELP! Wave spawner not working :( 2 Answers
Random Spawning 1 Answer
How do i make a spawing level? 1 Answer
Remmember the spawner 2 Answers