rmp::behavior::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 |
heading_for
The waypoint it is heading for, an index into waypoints.
from
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.