I just tried coding that and had the same problem.
I coded “System.runtime every frame, if VAR =1,turn clockwise 2”
When sprite senses touch down, if VAR = 0, set VAR to 1
When sprite senses touch down, if VAR = 1, set VAR to 0
I tested Touchup, Pressed, Clicked, CLick down, CLick up.
The sprite wouldn’t stop turning.
Maybe if you make some sort of delay when changing the variables value.
So the variable only changes a tenth of a second after press down. @Ready
@Infinitum3D and @Suzzy-Grey . Try using different values for “Runtime” and maybe sometimes use the timer. As practice shows, after the last update we can solve many complex problems and the logic of the work looks correct. Perhaps in some cases you may have problems with this, but otherwise everything should work correctly.
@Infinitum3D - Please send a link to your project, I’ll try to help you implement the logic for the your project…
This problem of avoiding a race condition is an interesting one! (for me, anyhow )
There surely are multiple successful approaches but I would like to share a solution I found using button states and a semaphore. The approach works like this: we can exploit button states (touch down, touch up) to detect sequential events within a single frame. On button down, we claim the semaphore (aka lock) that allows us to change the rotation state of our game object on the following button up event.
In the demo I’ve included extra variables to visualize the internal state, but in a game they can be omitted.