Hello there,
In order to make inputs more responsive, I’d like to add some kind of input buffering that tries to execute a function every tick until it either succeeds or exceeds a specified duration. For example, if the Jump Input Action is triggered while the player cannot jump, register it and retry every tick for 500ms. This way the character will jump even if the input was pressed too early.
I could make variables for every buffered action, but it would be nice to create some sort of reusable code block to avoid polluting the code and the duplicates.
There are some interesting questions/problems however, just a few:
- When should we add the input action to the buffer? On key release? E.g. what if the jumping is connected to the
Trigger
of its input action (so a longer keypress means a longer jump)? - It should handle “refreshing” the input action’s timer if the same input action is triggered
My main idea was to require a function to return true/false, where true
would mean that the function was executed successfully, so the input action can be removed from the buffer. I was trying to solve this with timers but eventually I gave up.
Is there any sophisticated way to handle this problem? (It is one of the top requirements of a feels-good platformer, for example).
Related question: (5-00) Making Inputs more forgiving
Thanks.