[SOLVED] Condition checking whether Animation Number is odd or even

Basically, I have a menu bar where the left right buttons change the middle button and clicking on the middle button plays the pressed animation and letting go reverts to unpressed animation.

I have numbered the animations such that odds are ‘pressed’ and even are ‘unpressed’ (including 0 - if 0 can be considered even).

Screenshot 2024-07-07 10.23.59 PM

Is there a way to check if animation (by number) is odd or even (i.e. animation number % 2 = 0)?

As I am limited to only one picture per post - here is the code.

There is condition Compare Two Numbers

You can mod number of animation and check if its equal to 0 or 1
Modulo expression is like looping number around some range
For example imagine you have seconds counter and seconds go from 0 to 999
But you want them to count from 0 to 9 then go back to 0 and start counting over
You would use mod(YourSeconds,10)
Same if you would want 60 sec out of it mod(YourSeconds,60)

Anyway you can also do it to animation and go with mod(Animation,2)
And instead it goes with animation 0 1 2 3 4 5 6 7 8 9… it will go with 0 1 0 1 0 1 0 1 0 1 0 1 0 1…
And by checking if its equal to 0 or 1 you would determine if its even or odd number

Ooh! That is super cool. Thank you!

I will play with this option more!

How do I mark this as solved?

Scroll this page to very top
Right from title of your topic you should see pencil
Click it and add [SOLVED] on the left then hit OK button

1 Like