Pawn mover: walk waypoints at a configurable speed #80

Closed
opened 2026-09-07 20:56:31 +01:00 by liamjd · 0 comments
Owner

Part of milestone #4. Depends on #77.

The thing that turns a find_path() result into a capsule moving across the map. Lives on PawnView; the record only holds state.

Design:

  • PawnView.follow(path: PackedVector3Array): stores waypoints and moves toward the next one each _process at speed tiles per second, consuming waypoints as it reaches them. Empty path is a no-op.
  • Y comes from the terrain under the current XZ (map.height_at()) plus half the pawn height, so the capsule rides terraces rather than cutting through them between waypoints.
  • Faces the direction of travel (rotate on Y only).
  • arrived signal when the last waypoint is reached; stop() clears the path.
  • The record's state and cell are updated by the registry on the view's signals, so Pawn stays a plain record with no node reference.
  • speed is an @export on the view and mirrored from the record on spawn, so speed is per pawn and tunable in the inspector.
  • remaining_path() accessor for the debug overlay issue.

AC:

  • Unit test with a PawnView added via add_child_autofree and a flat TerrainGrid: after follow() and a known total delta, the pawn has moved the expected distance along the path; arrived fires exactly once; stop() mid-path leaves it where it is.
  • Headed check: a pawn given a path across a terrace walks up the step, not through it.
Part of milestone #4. Depends on #77. The thing that turns a `find_path()` result into a capsule moving across the map. Lives on `PawnView`; the record only holds state. Design: - `PawnView.follow(path: PackedVector3Array)`: stores waypoints and moves toward the next one each `_process` at `speed` tiles per second, consuming waypoints as it reaches them. Empty path is a no-op. - Y comes from the terrain under the current XZ (`map.height_at()`) plus half the pawn height, so the capsule rides terraces rather than cutting through them between waypoints. - Faces the direction of travel (rotate on Y only). - `arrived` signal when the last waypoint is reached; `stop()` clears the path. - The record's `state` and `cell` are updated by the registry on the view's signals, so `Pawn` stays a plain record with no node reference. - `speed` is an `@export` on the view and mirrored from the record on spawn, so speed is per pawn and tunable in the inspector. - `remaining_path()` accessor for the debug overlay issue. AC: - Unit test with a `PawnView` added via `add_child_autofree` and a flat `TerrainGrid`: after `follow()` and a known total delta, the pawn has moved the expected distance along the path; `arrived` fires exactly once; `stop()` mid-path leaves it where it is. - Headed check: a pawn given a path across a terrace walks up the step, not through it.
Sign in to join this conversation.
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
liamjd/UntitledColonyBuilder#80
No description provided.