Skip to main content

Jumper

Jumper2DBehavior and Jumper3DBehavior implement focused jump physics: coyote time, jump buffering, multi-jump, variable jump height, and ground probing. Unlike Platformer, they do not provide a full walk/run character controller—pair them with your own horizontal movement or with FirstPersonBehavior / coordinators for FPS-style air control.

Minimal example (2D)​

website/snippets/behaviors/catalog/jumper.ts:

import { Jumper2DBehavior } from '@zylem/game-lib/behavior';

const jumper = hero.use(Jumper2DBehavior, {
jumpHeight: 3,
maxJumps: 2,
coyoteTimeMs: 120,
});

hero.onUpdate(({ inputs }) => {
hero.$jumper2d.jumpPressed = inputs.p1.buttons.A.pressed;
hero.$jumper2d.jumpHeld = inputs.p1.buttons.A.held > 0;
hero.$jumper2d.jumpReleased = inputs.p1.buttons.A.released;
});

Options​

OptionRole
jumpHeight, gravity, maxFallSpeedArc shape and terminal velocity.
maxJumps, resetJumpsOnGroundMulti-jump and reset rules.
coyoteTimeMs, jumpBufferMsForgiving ledge and input timing.
variableJumpCut gravity while holding jump.
groundRayLength, snapToGroundDistanceGround detection and snap.

3D adds planar air control, wall jump reset options, and integrates with $jumper input via FirstPersonShooterCoordinator.

Handle​

  • getState(), isJumping(), getJumpsUsed(), getJumpsRemaining() (2D).

Pitfalls​

  • Write edge-triggered jump fields (jumpPressed, jumpReleased) consistently; buffered jumps depend on them.
  • 2D jumper uses transformStore for vertical velocity intent; avoid duplicating gravity in onUpdate.

API reference​