With variable jump height, the longer you hold jump, the higher you go: a tap gives a 1.1-tile hop and a full hold gives 3.6 tiles. One button then covers both a low ceiling and a tall wall.

Timing diagram Variable jump height
With the technique You let go 150 ms in: gravity triples and the jump comes out shorter.
Without it Letting go does nothing: every jump is the full 3.6 tiles.
Drag the marker or use the arrow keys: it is the moment you let go of jump.
  • hold window (380 ms): with the technique, You let go n ms in: gravity triples and the jump comes out shorter. without it, Letting go does nothing: every jump is the full 3.6 tiles.

Variable jump height: a tap hops, a hold jumps

Obstacles ask for different heights. A spiked ceiling wants a short hop, a wall wants the whole jump. Variable jump height lets the player pick any height between 1.1 and 3.6 tiles with the same button, and the button reads the hold the way players already expect. Without it, every obstacle in the game has to be designed around one arc.

How to implement variable jump height

  1. Watch for the release while rising. If the button comes up while the character still moves upward, mark the jump as cut.
  2. Raise gravity until the top. A cut jump rises with gravity ×3, so the arc bends instead of breaking. Halving the upward speed on release also works, but the arc gets a visible kink at that instant.
  3. Cut once per jump. Pressing again mid-air must not undo it.
  4. Protect wall jumps. Block the cut for the first 220 ms of a wall jump, or someone mashing the button against a wall loses height on every kick.
The code in Godot 4
addons/platformer_kit/player/player.gd
# SALTO VARIABLE: soltar el botón mientras se sube multiplica la gravedad.
# Toque corto = saltito; mantener = salto completo.
if _jumping and not _jump_cut and velocity.y < 0.0 and not jump_held \
		and _wall_jump_hold <= 0.0 and Lab.on(&"variable_jump"):
	_jump_cut = true
	jump_cut.emit()

var gravity: float
if velocity.y < 0.0:
	gravity = p.gravity_up
	if _jump_cut:
		gravity *= p.jump_cut_gravity_mult

jump_cut_gravity_mult is 3, and it is the only number to tune.

Quick answers

How short should a short hop be?

About 30% of a full jump: 1.1 tiles against 3.6. Low enough to stay under a three-tile spiked ceiling, long enough (2.5 tiles at a run) to clear a two-tile gap.

Should I cut the velocity or raise the gravity?

Raise the gravity if you want the arc to stay smooth; cut the velocity if you want the release to be visible. Both work.

How long should the hold window be?

Here the hold counts all the way to the top, 0.38 s. Celeste caps it at 0.2 s: while you hold, the upward speed doesn't drop.