Skip to content

@modoki/engine / index / CharacterController2D

Variable: CharacterController2D

const CharacterController2D: Trait<{ autostepHeight: number; autostepMinWidth: number; gravityScale: number; grounded: boolean; jump: boolean; jumpSpeed: number; maxSlopeClimbDeg: number; minSlopeSlideDeg: number; moveX: number; readbackReady: boolean; skin: number; snapToGroundDist: number; speed: number; velY: number; }>

CharacterController2D — a kinematic, gravity-obeying player controller driven by Rapier's KinematicCharacterController (collide-and-slide + autostep + slope limits + snap-to-ground). Pair with a kinematic RigidBody2D + a Collider2D (box/capsule). The physics system reads the INPUT fields each tick, computes a collision-safe movement, moves the body, and writes the READBACK fields.

Determinism: the controller reads only trait fields (never the DOM), so a headless test drives it by setting moveX/jump (e.g. via a dispatched action). In the live app the engine's characterInputSystem maps the InputManager's keys onto those fields.

Built with Modoki.