Skip to content

@modoki/engine / index / CharacterController3D

Variable: CharacterController3D

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

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

Horizontal movement is on the XZ plane (moveX/moveZ); +Y is up (gravity pulls down, jump launches up) — no axis flip, unlike the 2D controller. Determinism: the controller reads only trait fields (never the DOM), so a headless test drives it by setting moveX/moveZ/jump. In the live app a 3D input system maps keys onto those fields.

Built with Modoki.