miaoda-game-traversal-core
v0.3.0
Published
Engine-agnostic input-driven constrained-path traversal for stairs, ladders, ropes, rails, vines, and pipes: explicit attach/detach, signed movement, endpoint events, facing, and stable snapshots.
Maintainers
Readme
miaoda-game-traversal-core
Engine-independent, input-driven movement constrained to an explicit path. Use it for stairs, ladders, ropes, vines, rails, and pipes without adding those modes to the normal platformer body.
pnpm add miaoda-game-traversal-core miaoda-game-path-coreconst route = {id: 'hall-stairs', path: new BakedPath(new PolylinePath([{x: 32, y: 16}, {x: 128, y: 80}]))};
const traversal = new TraversalBody({speed: 48});
traversal.attach(route, 'start');
const frame = traversal.step(1 / 60, {axis: input.vertical});
setActorPosition(frame.position);dt is seconds, speed is path units per second, and axis is clamped to -1..1: positive moves start-to-end. angleDeg follows the directed tangent. attach/attachAtDistance snap immediately, with justAttached emitted by the next step.
reachedEndpoint is a one-tick event; atEndpoint is persistent state. With autoDetachAtEndpoints, the arrival tick also reports justDetached while preserving endpoint position/facing. Route discovery, attachment permissions, collision, gravity, attacks, animation, and transitions back to normal movement remain game-owned.
