# rmp::behavior::Chase

> Sees a target and goes after it.

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

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

struct Chase

Sees a target and goes after it. It sees it within `sight` units, inside a cone of `fov` degrees around the way it faces, and — with `line_of_sight` — when no solid map cell stands between them. While it chases, a Patrol on the same object is paused, and a Pathfind, when there is one, finds the way; without one it runs straight at the target. After `lose_after` seconds without seeing it, it gives up: on_lose, back home with `return_home`, and the Patrol resumes.

From the editor: "speed" (Float), "sight" (Float), "fov" (Float).

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

## Fields

| Field | Type | Default | What it is |
|---|---|---|---|
| `target` | `Handle<Object>` |  | Whom it looks for; the game sets it, usually the player |
| `speed` | `float` | `120` | Units per second while it chases |
| `sight` | `float` | `160` | How far it sees; 0 = any distance |
| `fov` | `float` | `360` | Degrees of its view, centred on the way it faces |
| `line_of_sight` | `bool` | `true` | Solid map cells hide the target |
| `lose_after` | `float` | `2` | Seconds without seeing it before it gives up |
| `return_home` | `bool` | `true` | Goes back where it started after giving up |
| `stop_distance` | `float` | `0` | Stops this close to the target |
| `on_spot` | `Callback<Object &, Object &>` |  | (the chaser, the target), when a chase starts |
| `on_lose` | `Callback<Object &>` |  | When it gives up |
| `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. |

### `chasing`

bool chasing() const

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

Whether it is chasing now.

### `sees`

bool sees() const

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

Whether it saw the target at its last update.

### `from`

static Chase from(const MapObject &object)

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

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