Hello everyone,I’m sorry for my bad english I have a score and an animation in Unity. I want to play the animation when the score is a multiple of 200, but I don’t know how to explain the multiples of 200 in C# please help me thank you in advance
You can do this with the modulus (%) operator.
Take your score as an int
public int _score;
// Then check if score is divisible by 200
void Start()
{
if ((_score % 200) == 0) {
// Run your animation
}
}
Hope that helped!
get a score in (int or float).
eg) int score;
if(score%200==0)
{
//start animation
}
Hello again, I’m sorry, I may have expressed myself wrong because my English is bad, for example, when the score is 200, I want to play the animation once. When it reaches 400, I want to play it again. When it reaches 600, I want to play it again and I want it to go like this until the score is 5000.
hey @ajanm9387 , Its okay just clarified the question. If thats the case the script should have a reference to the score and animation it wants to check and play. Then it may go something like
int c;
void Update(){
//get score here
if(score>=c ){
c+=199;
//play animation
played=true;
}
}
Hope this helps.
Edit: Some typos and i copy pasted some code snippets here. Sorry.