The playground link closely resembles what I’m trying to do.
The idea: If there is any available energy you can sprint
The problem:
If I first press SHIFT and then a button you sprint but the energy doesn’t deplete but you run.
If I first press an ARROW KEY and then press the SHIFT key energy depletes and you run.
If I press an ARROW KEY and then press the SHIFT key BUT then press a different ARROW KEY while still holding the SHIFT key you run but the energy doesn’t deplete.
How can I implement the running ability correctly ? What am I missing ?
Doing what you did rely on the repeat rate of the keyboard event when you keep a key pressed, and the repeat event is not sent anymore when you press another key at the same time.
You should instead simply put flags to know if the keys your are interested in are pressed or not:
Thank you very much. I feel so dumb over this but for some reason I was hesitating to use the renderObservable cause I don’t know if it was appropriate for these type of things
@Evgeni_Popov It feels like a spring on keyUp() of WASD since it resets the state of running,walking,standing but feels good I think. You can see it live if you please !