Module character

Source
Expand description

Kinematic upright capsules and planar boxes, shared by games and prediction. Positive Y is up. Positions are feet/sole centers. Move terrain first, then motors.

Character::reset clears motion/support/jump history at checked coordinates; Character::teleport additionally resolves destination overlaps and acquires current walkable support. After either succeeds, hosts must set both previous and current interpolation poses to the resolved character position, including camera history on a restart. Do not interpolate across the old and new locations. Discard pending host gameplay edges on restart; neither method advances a tick. Motion::recovery separates overlap correction from gameplay movement, and Motion::support_motion reports attempted versus applied platform carry. check_clearance and Character::try_set_height never recover, snap or advance time. Height changes preserve the sole position and all motor history; the caller continues to pass the accepted shape to subsequent motor steps.

Structs§

Character
CharacterInput
CharacterSettings
CharacterStep
Clearance
A complete, nonpenetrating clearance query. Touching is allowed, using the motor’s existing 1e-5 penetration tolerance; skin is not added to the shape.
JumpState
Motion
Obstacle
QueryBounds
Recovery
Overlap corrections performed during one successful move, step or teleport. This excludes requested motion, platform carry and ground snap. Errors still return no partial motion and leave a Character unchanged.
Support
SupportMotion
Motion requested by the previous supporting obstacle during a fixed tick.

Enums§

CharacterError
CharacterShape
ClearanceError
Failure of a clearance query or checked height change. This separate type preserves exhaustive matches on the existing CharacterError.
ObstacleShape

Traits§

Terrain
The visitor receives current poses. Implementations may use their broadphase; they must visit every obstacle intersecting bounds, in deterministic order. Character queries allocate no scratch buffers. Sensors/layers are filtered by the motor.

Functions§

check_clearance
Check the current terrain for penetration at fixed feet coordinates, without recovery, ground snap, support lookup or scratch allocation. Uses the same shape/obstacle separation and filtering as the motor. Touching is clear, with the existing 1e-5 penetration tolerance (no extra skin clearance).
move_and_slide
Sweep/slide without applying acceleration, gravity or jump state. Displacement may be long; no destination-only collision tests or discrete movement substeps. A bounded starting-overlap recovery is attempted; errors leave caller state intact.