Coyote Time (also called "grace period") is a game design technique that allows players to jump for a brief period of time even after they've walked off a platform. People have a reaction time and don't necessarily press the jump button right before falling off a ledge. Coyote Time compensates for this and makes gameplay feel more fair.
It's one of many techniques game designers use to "cheat" and make games feel more responsive and enjoyable to play.
The technique is named after the cartoon character Wile E. Coyote, from the Looney Tunes series Road Runner, who could briefly hover in mid-air before falling off cliffs.
The implementation is simple: the game tracks how long the player has been falling and still allows jumping if this time is less than the defined Coyote Time window (typically around 0.1 to 0.2 seconds). Here's a simple example of how to implement Coyote Time in GDScript:
const COYOTE_TIME_WINDOW = 0.1
var time_in_air := 0.0
func _physics_process(delta: float) -> void:
if is_on_floor():
time_in_air = 0.0
else:
time_in_air += delta
if Input.is_action_just_pressed("jump") and (is_on_floor() or time_in_air < COYOTE_TIME_WINDOW):
velocity.y = -jump_force
In this example, time_in_air
is reset to 0 when the player is on the floor. If the player jumps while in the air, the game checks if they are on the floor or if they have been in the air for less than COYOTE_TIME_WINDOW
seconds. If either condition is true, players can jump.