# 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`.

Source: https://omardev29.github.io/rmp-docs/reference/behaviors/Pathfind.html

behavior `#include <rmp/behavior.h>` [include/rmp/behavior.h:822](https://github.com/omardev29/raylib_multiplatform/blob/982bf2a1e307c49776bff84211260703b8de6895/include/rmp/behavior.h#L822-L854)

struct Pathfind

Walks to a target, or to a point, around the map's walls: [`rmp::find_path()`](https://omardev29.github.io/rmp-docs/reference/namespaces/rmp.html#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 `{ .speed = 320 }` stops compiling — which is the whole design. The name is the fence. |

### `path`

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

function [include/rmp/behavior.h:831](https://github.com/omardev29/raylib_multiplatform/blob/982bf2a1e307c49776bff84211260703b8de6895/include/rmp/behavior.h#L831-L836)

The cells still ahead, the last one the goal.

### `arrived`

bool arrived() const

function [include/rmp/behavior.h:838](https://github.com/omardev29/raylib_multiplatform/blob/982bf2a1e307c49776bff84211260703b8de6895/include/rmp/behavior.h#L838)

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