miaoda-game-platform-nav-core
v0.3.0
Published
Engine-agnostic navigation for gravity-driven 2D platformers: deterministic weighted routing over directed walk, jump, drop, climb and custom links; runtime capability filtering; partial routes; movement intents; and pure jump-arc reachability helpers.
Downloads
477
Maintainers
Readme
miaoda-game-platform-nav-core
Engine-independent navigation over authored/baked platformer waypoints connected by walk, jump, drop, climb, door, teleport, or custom links. It chooses routes and emits traversal intent; physics and the character controller execute that intent.
pnpm add miaoda-game-platform-nav-coreconst graph = new PlatformNavGraph();
graph.addNode({id: 'floor', position: {x: 40, y: 0}});
graph.addNode({id: 'ledge', position: {x: 150, y: 72}});
graph.addLink({id: 'jump', from: 'floor', to: 'ledge', kind: 'jump', requiredCapabilities: ['jump']});
const agent = new PlatformNavAgent(graph, {waypointTolerance: 8});
agent.plan(enemy.position, exit.position, {capabilities: ['jump'], allowPartial: true});
const intent = agent.next(enemy.position); // once per fixed/physics tick
enemy.setHorizontalInput(intent.moveX);
if (intent.action === 'jump' && intent.actionStarted) enemy.pressJump();Links are directed unless bidirectional; capability matching is all-of. Routes are deterministic and include oriented links, total cost, and whether the goal is complete. With allowPartial, the best reachable endpoint is returned.
solveJump uses +Y up, fixed jump speed, gravity, and maximum horizontal speed. Provide isSegmentClear when baking to verify body clearance; screen-y-down games should adapt coordinates. actionStarted is a one-tick edge. Action success, stuck detection, replanning, moving platforms, collision, and local avoidance remain host responsibilities.
