rmp::behavior::Pathfind
Walks to a target, or to a point, around the map's walls: rmp::find_path(), asked again every repath_every seconds, and followed at speed. Top-down: it moves on both axes. A Chase on the same object steers it.
Added to an object with add<rmp::behavior::Pathfind>(); the framework calls its _update with the object it is on.
Fields
| Field | Type | Default | What it is |
|---|---|---|---|
target | Handle<Object> | Where it goes, while it is there | |
goal | std::optional<Vector2> | Where it goes without a target; empty = it stays | |
speed | float | 100 | Units per second |
diagonal | bool | true | Eight directions; false = four |
clearance | float | 0 | Keeps this far from the walls; see PathOptions |
repath_every | float | 0.5f | Seconds between two searches while it walks |
ours | struct { … } | What it is keeping track of. Readable, because sometimes you want it; not yours to write. It is one PUBLIC member and not a private block because a struct with a private member is not an aggregate in C++20, and then |
path
The cells still ahead, the last one the goal.
arrived
Whether it is where it was going: at the goal, or with no way there.