# rmp::behavior::Patrol

> Goes from waypoint to waypoint -- round in a loop, or back and forth with `ping_pong` -- waiting `wait` seconds at each.

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

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

struct Patrol

Goes from waypoint to waypoint — round in a loop, or back and forth with `ping_pong` — waiting `wait` seconds at each. With no waypoints it walks the floor instead: left and right at `speed`, turning at a wall and, with `turn_at_ledges`, before a drop, which is a platformer's goomba. The way it goes sets flip_x, and its sprite plays `walk` and `idle` when its sheet has them — unless the object has an Animator, which then chooses.

Waypoints are for what flies or walks top-down: it moves straight to each, on both axes. Floor walking moves only along x, and gravity is the object's.

From the editor: "path" (Array<Point>; the entity's own position is the first waypoint), "speed" (Float), "wait" (Float), "ping_pong" (Bool).

Added to an object with `add<rmp::behavior::Patrol>()`; the framework calls its `_update` with the object it is on.

## Fields

| Field | Type | Default | What it is |
|---|---|---|---|
| `waypoints` | `std::vector<Vector2>` |  | World positions; empty = it walks the floor |
| `speed` | `float` | `60` | Units per second |
| `wait` | `float` | `0` | Seconds it stays at each waypoint |
| `ping_pong` | `bool` | `false` | Back and forth; false = from the last straight to the first |
| `turn_at_ledges` | `bool` | `true` | Walking the floor: turns before a drop |
| `walk` | `std::string` | `"walk"` | The tag played while it moves; "" = none |
| `idle` | `std::string` | `"idle"` | The tag played while it waits; "" = none |
| `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. |

### `heading_for`

int heading_for() const

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

The waypoint it is heading for, an index into `waypoints`.

### `from`

static Patrol from(const MapObject &object)

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

A Patrol with the fields the map's entity has by these names — path, speed, wait, ping_pong — and the defaults for the rest. See "FROM THE EDITOR" at the top of this file.
