- Home /
C# Check If Minutes equal some denomination of 5
I need to check if my integer variable minutes equals some denomination of 5. I went looking for some sort function that does this. But from what I could find there isn't any. Will I need to create my own? I have some pseudocode as to how I think it might look like. public int minutes;
void Update () {
minutes = (int)Time.time / 60;
if( minutes == a denomination of 5){
Debug.Log("minutes currently equals" + a denomination of 5)
}
}
Answer by Flink91 · Feb 11, 2016 at 10:42 PM
So you want it to show "minutes currently equals 5/10/15/20/25..." ? Then you can use the modulo operator: % .
if( minutes%5 == 0){
Debug.Log("minutes currently equals" + minutes);
}
Answer by alankemp · Feb 11, 2016 at 11:46 PM
Use the mod operator %.
https://msdn.microsoft.com/en-us/library/0w4e0fzs.aspx?f=255&MSPPError=-2147217396
if ((minutes % 5) == 0)
{
Debug.Log("minutes currently equals" + a denomination of 5)
}
Answer by Orbayd · Feb 11, 2016 at 11:47 PM
i think what you are looking or % operator so
if( minutes % 5 == 0 ) {
// every five minutes do this
Debug.Log("minutes currently equals" + a denomination of 5)
}
Your answer
![](https://koobas.hobune.stream/wayback/20220612063850im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Checking How Many Minutes Have Passed This Day? 1 Answer
Pacman ghost behaviour 0 Answers