Input buffering, coyote time


To make a game like that feel responsive I implemented input buffering. It's a neat technique that meshes well with things like animations and actions with cooldowns.

Imagine a simple jumping mechanic in a 2D platformer. Usually it's implemented with a isGrounded flag. If player is on the ground and he presses jump button, the character jumps. This however makes is feel unresponsive when player presses jump button a frame before landing on the ground (when doing pogo jumping for example).

To fight it, an input buffer is used. Each action (for example jump action) would store a time it was last performed action.lastPerformed = now. In the fixed update (where physics should happen) we simply compare if now - action.lastPerformed < timeWindow. If so, we consume that action and act on it. This is a useful trick that can make games feel more responsive by introducing Coyote time as well — grounded flag would become a grounded timer, and we could check how long ago did a player loose footing. If the time is not that long, we allow for jump to be made.

This game uses this exact mechanic to respond to fast user clicks and give a feeling of snappy controls even when a character is mid-animation.

This is my implementation of a technique described in this superior GDC talk (more precisely 8:44 time mark).

Files

Chapter01.zip Play in browser
Jul 14, 2023

Leave a comment

Log in with itch.io to leave a comment.