Godot Platformer Controller: Coyote Time and Jump Buffer
A Godot 4 platformer controller that feels fair: a jump set by its height and time, coyote time, a jump buffer, short hops and heavier falls, all tested.

Your playtester runs to the edge of a platform, presses jump and drops into the pit. "I pressed it!" They did, a frame or two after the feet left the ledge. On the way down they press jump again just before landing, and nothing happens. The jump drifts up and drifts down, and a quick tap jumps as high as holding the button. The player calls the controls floaty or stiff.
Godot is doing what the script says. A plain jump script jumps only on a frame where is_on_floor() is true, and at 60 physics frames a second one frame is about 17 ms. Players press a little late at ledges and a little early on landings all the time, and each of those presses is lost.
Below is what a plain script does in Godot 4.7.2, then a controller with coyote time, a jump buffer, variable jump height and heavier falls, run frame by frame.
1. What a plain jump does
The usual first script adds get_gravity() * delta in the air, sets velocity.y = -400 when jump is pressed on the floor, and calls move_and_slide(). We ran it on a flat floor and off a ledge:

- Godot's default gravity is 980 pixels a second² (Project Settings > Physics > 2D > Default Gravity,
physics/2d/default_gravity).get_gravity()on the body returned (0, 980). - The jump rose 85 px, 25 frames up and 25 down. A fall as slow as the rise is what players read as floaty.
- A one-frame tap rose 85 px too, so there is no short hop.
- Pressing jump on the first frame after walking off a ledge did nothing. Frames 2 to 9 did nothing either.
- A press one frame before landing did nothing. Only a press on the ground jumped.
2. Set the jump by its height and time
A speed like -400 is hard to design with. You know how high the jump should go and how long it should take. For a body thrown up at speed v against gravity g, the top is h = v² / 2g, reached after t = v / g, so:

- gravity = 2h / t²
- jump speed = 2h / t, negative in Godot because y points down
A 56 px jump (3.5 tiles of 16 px) that peaks after 0.35 s gives a gravity of 914.3 and a jump speed of -320.
3. The controller script
Attach this to a CharacterBody2D with a CollisionShape2D. It uses Godot's built-in ui_ actions, so it runs in a new project with no setup: the arrow keys or a gamepad's D-pad and left stick to move, Space or Enter to jump.
extends CharacterBody2D
@export var speed := 120.0
@export var acceleration := 1800.0
@export var jump_height := 56.0
@export var time_to_apex := 0.35
@export var fall_gravity_scale := 1.5
@export var max_fall_speed := 400.0
@export var coyote_time := 0.1
@export var jump_buffer := 0.12
var gravity := 0.0
var jump_velocity := 0.0
var coyote_timer := 0.0
var buffer_timer := 0.0
func _ready() -> void:
gravity = 2.0 * jump_height / (time_to_apex * time_to_apex)
jump_velocity = -gravity * time_to_apex
func _physics_process(delta: float) -> void:
if is_on_floor():
coyote_timer = coyote_time
else:
coyote_timer -= delta
var g := gravity if velocity.y < 0.0 else gravity * fall_gravity_scale
velocity.y = minf(velocity.y + g * delta, max_fall_speed)
if Input.is_action_just_pressed("ui_accept"):
buffer_timer = jump_buffer
else:
buffer_timer -= delta
if buffer_timer > 0.0 and coyote_timer > 0.0:
velocity.y = jump_velocity
buffer_timer = 0.0
coyote_timer = 0.0
if Input.is_action_just_released("ui_accept") and velocity.y < 0.0:
velocity.y *= 0.5
var axis := Input.get_axis("ui_left", "ui_right")
velocity.x = move_toward(velocity.x, axis * speed, acceleration * delta)
move_and_slide()
What each part did in Godot 4.7.2, at 60 physics frames a second, on a 12 x 24 px body:
- Coyote time.
coyote_timeris filled to 0.1 s on every frame on the floor and counts down in the air, and a jump works while it is above 0. Walking off a ledge at 120 px a second, a press on air frames 1 to 6 jumped, and on frame 7 the body kept falling. Six frames is 12 px past the edge. - Jump buffer. A press fills
buffer_timerto 0.12 s, and the jump happens on the first frame both timers are above 0. A press made 7 frames before landing jumped on the landing frame; 8 frames before, it did not. Both timers go to 0 on the jump, so a press in the air after a jump waits for the ground and never jumps in mid-air. - Variable jump height. Letting go while rising halves the speed. Held, the jump rose 58.7 px. Let go one frame after the press, it rose 19.4 px.
- Heavier falls. Gravity is 1.5 times stronger on the way down: 21 frames up, 19 down.
max_fall_speedcaps long falls at 400 px a second. - Acceleration.
move_toward()took the body from standing to 120 px a second in 4 frames, and the same rate brings it back to 0 when you let go.
4. Why it rose 58.7 px and not 56
The formulas assume smooth time, and Godot moves the body once per physics frame. The jump climbs in 21 steps and overshoots by one step in 21: 56 × 22 / 21 = 58.7 px. To get the height you typed, work gravity out from the frame count. Replace _ready() with this:
func _ready() -> void:
var dt := 1.0 / Engine.physics_ticks_per_second
var n := roundi(time_to_apex / dt)
gravity = 2.0 * jump_height / (dt * dt * n * (n + 1))
jump_velocity = -n * gravity * dt
That version rose 56.07 px. The last 0.07 px is the body's Safe Margin, 0.08 by default; with it set to 0.001 the jump rose 56.00 px.
The timers have an edge of the same kind. 0.1 s is exactly 6 frames, so on air frame 6 the coyote timer was above 0 by a rounding error, about 0.00000000000000002 s, so frame 6 counted by luck. Counting whole physics frames instead of seconds makes the window exact.
5. What a full controller still needs
A game also needs one-way platforms you drop through with down + jump, a run button, maybe air jumps, and animations that follow the state (idle, walk, run, jump, fall), mirrored in place when the character turns.
The fast way: the Godot Platformer Character Builder
The Godot Platformer Character Builder builds all of this around your own character, in your browser, and never uploads your art.
- Drop the character. A side-view sheet with the JSON from our packs, Aseprite or TexturePacker, or loose frames named like run_1.png. Idle, walk, run, jump and fall are found for you, the left side is mirrored when only the right is drawn, a missing fall holds the jump's last frame, and attacks play once. Or start from ours: a knight, a ranger with a bow, or a zombie drawn facing left.
- Set the jump as in section 2. A height in pixels and a time to the top, plus short hop, fall gravity, coyote time, jump buffer, air jumps and top fall speed. For 16 px tiles it starts at 56 px in 0.35 s, 100 ms of coyote time and a 120 ms buffer, the numbers used above; 32 and 64 px tiles are there too.
- Play it. Watch the tour or play the test level: A/D or the arrows, Shift to run, Space to jump (hold it to go higher), J to attack, S + Space to drop through the plank. Under it you see the held jump in pixels and tiles, the tap, the time in the air, how many tiles a walking and a running jump clear, and the coyote time and buffer in frames.
- Download the ZIP. A CharacterBody2D scene with the sprite on its feet, the typed script with every setting in the Inspector, a SpriteFrames, and the same test level with steps, a gap, a one-way plank and a ceiling to press F6 on.
Its script works gravity out per physics frame, so a held jump rises exactly the height you set, and counts coyote time and the buffer in whole frames. It sends jumped, landed and action_finished, and adds its input actions only when your project lacks them. Every file was checked in Godot 4.7.2.
Open it with a free Gridwright account, made with only your email: every feature works on your own sheets, our three sample characters are a click away, and your work is saved. Downloading the Godot platformer comes with Pro.
Every Gridwright asset pack, made to fit together, and all 44 tools for the fiddly work, with every new release, for $17 a month. Try it in your own game first: 3 days for $1 with every tool and up to 10 packs. Cancel any time.
Start: 3 days for $1 See everything it includesFAQ
What is coyote time in Godot?
A short window after the character leaves a ledge in which jump still works. CharacterBody2D has no setting for it: fill a timer on every frame on the floor, count it down in the air, and allow the jump while it is above 0. The tool starts at 0.1 s, 6 frames at 60.
How do I add a jump buffer in Godot 4?
Input.is_action_just_pressed() fills a timer that counts down every frame, and the jump happens on the first frame on the floor (or in coyote time) while it is above 0. Empty it when the jump happens.
Why does my Godot jump feel floaty?
In the plain script the fall takes as long as the rise, 25 frames each, and a tap jumps as high as a hold. Use more gravity on the way down and cut the speed when jump is let go while rising.
Try it on your character
Open the Godot Platformer Character Builder, drop your sheet and play the jump before it goes into your game. Side-View Characters has characters with the JSON it reads, and the Platformer Tileset has 16 px tiles for the level. More on the art in 2D Character Creator, and on sharp pixels in Godot Pixel Perfect Settings. The tool and the packs are part of Gridwright: 44 tools and 150 asset packs, 3 days for $1, then $17 a month.
Every Gridwright asset pack, made to fit together, and all 44 tools for the fiddly work, with every new release, for $17 a month. Try it in your own game first: 3 days for $1 with every tool and up to 10 packs. Cancel any time.
Start: 3 days for $1 See everything it includes