On this page
  1. Fields
    1. path
    2. arrived

rmp::behavior::Pathfind

behavior #include <rmp/behavior.h> include/rmp/behavior.h:822
struct 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

FieldTypeDefaultWhat it is
targetHandle<Object>

Where it goes, while it is there

goalstd::optional<Vector2>

Where it goes without a target; empty = it stays

speedfloat100

Units per second

diagonalbooltrue

Eight directions; false = four

clearancefloat0

Keeps this far from the walls; see PathOptions

repath_everyfloat0.5f

Seconds between two searches while it walks

oursstruct { … }

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 { .speed = 320 } stops compiling — which is the whole design. The name is the fence.

path

std::span<const Vector2> path() const

The cells still ahead, the last one the goal.

arrived

bool arrived() const

Whether it is where it was going: at the goal, or with no way there.