(SOLVED)How do I switch bars on key up?

This is a bit hard for me to explain. I’m trying to have one bar fill up while a key is held, but if you release the same key, it should switch and fill up the other bar. But it doesn’t and keeps filling up the first bar.

I hope these screenshots help explain what I’m trying to do.



This doesn’t work because the action in the first event sets the conditions to be met for the second event.


Refactor the events to:



mod, or modulo is a way to find out what’s left over when you divide one number by another. For example, if you divide 17 by 5, you get 3 with a remainder of 2, so mod(17,5) equals 2. This means that when you divide 17 by 5, the leftover is 2. In simpler terms, it helps us know how many times the divisor fits into the dividend, and the result is the leftover part.

So if CurrentAttack is 0, then (0+1) / 2 has a remainder of 1
If CurrentAttack is 1, then (1+1) / 2 has a remainder of 0

3 Likes

We can say that this is clear, MrMen!

And nice explanations on the Mod() function and the trick to get 0 or 1

1 Like

That worked! Thanks for your help!

1 Like