> For the complete documentation index, see [llms.txt](https://malbersanimations.gitbook.io/animal-controller/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://malbersanimations.gitbook.io/animal-controller/main-components/path-constraint/mpath.md).

# MPath

## Overview

MPath Component is the bridge between the Path Constrain and any Path/Spline solution you may use. It will take the values needed from a spline and it will translate them to constraint the character so it follows and stays on the path.

<figure><img src="/files/yfZaB7UREqbCdPNZUbND" alt=""><figcaption></figcaption></figure>

## How it works

The MPath will use any type of IPath component to get the spline/path values. If an animal using a Path Constraint component enters the Colliders Bound of this component then the search for the closest point on the spline will start. if both search radius (MPath and Path Constraint ) are near, and Automatic is set to true then the character will be constrained to the Path.

{% embed url="<https://streamable.com/imawmh>" %}

## Requirements

* Any type of collider set as a trigger. (Box Collider Recommended)
* Any type of IPath Component **(**[**Path Link (Straight)**](/animal-controller/main-components/path-constraint/path-link-straight.md)**,** [**Path Link Cinemachine**](/animal-controller/main-components/path-constraint/path-link-cinemachine-path.md)**,**[ **Path Creator**](/animal-controller/main-components/path-constraint/path-creator-sebastian-lague.md)**)**

## Parameters

### Path

<figure><img src="/files/7ESfaVDFBEoR7bi3F9l8" alt=""><figcaption></figcaption></figure>

#### IPath

Type of Path solution to use, you can use any of the 3 solutions included **(**[**Path Link (Straight)**](/animal-controller/main-components/path-constraint/path-link-straight.md)**,** [**Path Link Cinemachine**](/animal-controller/main-components/path-constraint/path-link-cinemachine-path.md)**,**[ **Path Creator**](/animal-controller/main-components/path-constraint/path-creator-sebastian-lague.md)**)**&#x20;

Add your solution to the path and then hit the refresh button.

<figure><img src="/files/5tpMFWzs0DdvFW06Qbw3" alt=""><figcaption></figcaption></figure>

#### Automatic

&#x20;The character will be constrained to the path as soon as both Search Radius instersect

<figure><img src="/files/q2f2t6dYE0mi78jqNYum" alt=""><figcaption></figcaption></figure>

Some paths are set to not be Automatic. To activate the, go to the Path Constraint component, add an Input connection, and use the method **`TryEnterExitPath().`**&#x54;his also works for exiting a path in the middle of it.

<figure><img src="/files/bWfuSDSPX6K8sLlF95Kx" alt=""><figcaption></figcaption></figure>

#### AutoChangePath

This allows to change automatically to a new path when the character is already in another path. The new path needs to be set to automatic also.

<figure><img src="/files/1E7tCfFt3XOvnNtSKNMB" alt=""><figcaption></figcaption></figure>

#### Lock Rotation

The character cannot rotate or change direction while on the path. (The character can walk backward)

<figure><img src="/files/Z8lu0UjX4Gu2MCQnJXxo" alt=""><figcaption></figcaption></figure>

#### Follow Direction (Lock Rotation = True)

<figure><img src="/files/2dx4l2z9Vtv1pJt9DL7t" alt=""><figcaption></figcaption></figure>

When lock rotation is true you can set the follow direction on the Path, this will automatically rotate the character to match the correct orientation during the path.&#x20;

* **None**: the Character will keep the starting path orientation when entering from the start or the end of the spline

|         Entering from End        |        Entering from Start       |
| :------------------------------: | :------------------------------: |
| ![](/files/HiGH9ii3eirOxrTilld6) | ![](/files/NWCbyUWgYdw2nYhNvXaS) |

* **Forward**: The Character will be oriented to the Forward Path orientation  (Start to End)

|         Entering from End        |        Entering from Start       |
| :------------------------------: | :------------------------------: |
| ![](/files/FBrMEGQfMKvkTlHpgnzx) | ![](/files/NWCbyUWgYdw2nYhNvXaS) |

* **Backward**: The Character will be oriented to the Backward Path orientation  (End to Start)

|         Entering from End        |        Entering from Start       |
| :------------------------------: | :------------------------------: |
| ![](/files/HiGH9ii3eirOxrTilld6) | ![](/files/zmIJzzm1KNnIIj4q0PI5) |

#### Use Path Rotation

The Character will follow also the Path rotation values

<figure><img src="/files/1i33y9jkY2T4IDyouL6k" alt=""><figcaption></figcaption></figure>

#### Alignment Offset

Applies an offset to the Character during the Path Constraint

#### Path Position

Use this Transform to have a gameobject follow the current position of the Character on the Path

<figure><img src="/files/UOlJY7bAIDKozEs5eMzr" alt=""><figcaption></figcaption></figure>

#### Can Exit on Start

The Character can exit automatically if it reaches the Start of the Spline

#### Can Exit on End

The Character can exit automatically if it reaches the Start of the Spline

#### Can Exit on Middle

The Character can exit automatically if a state interrupts the spline constraint. (E.g. Jumping on the middle of the spline)

<figure><img src="/files/Sj2pPwoQUsOexDO4HhYB" alt=""><figcaption></figcaption></figure>

#### &#x20;Interval

When the character is inside the Path bounds then a search will start to find if the character can be constrained when the search radius intersects. The interval is the time to execute this search. increase this value to increase performance. Reduce it to increase precision.

|         Interval  = 0.5f         |           Interval  =0f          |
| :------------------------------: | :------------------------------: |
| ![](/files/ljgJkawcuanUIE980vUd) | ![](/files/BBJUoObwEUocizaprVeY) |

#### Path Cooldown

Once the character activates the path constraint, this time will need to elapse in order to exit the path again. This is useful to avoid entering and exiting the path in the same frame.

#### Search Radius

Radius to search a nearby Path Constraint component. When the Path Constraint sphere trigger and the Path sphere triggers intersect. It means the Character can activate a path.

#### Search Offset

An offset of the Radius value relative to the Path position.

<figure><img src="/files/XOHGugDzHmEbSWUt4RJV" alt=""><figcaption></figcaption></figure>

#### Path Bounds

Collider assigned to the Path. This allows us to calculate searching for a character only when a character is inside the trigger.

<figure><img src="/files/0LbHYcXhHOE4FeUaLWPP" alt=""><figcaption><p>Box collider to limit the path bounds</p></figcaption></figure>

#### Layer

Filter what Layer can be used on the Paths  (Animal Layer is the Default).

### Animal

<figure><img src="/files/invnoel8oDuRM7gfIayF" alt=""><figcaption></figcaption></figure>

#### Activate State

What state to activate when entering the path

#### Ignore Vertical

When is active the Animal cannot move on the Y-Axis while is on the path.  Disable this if you want to Jump while on the path.

(img)

#### Ignore Grounded

Ignore grounded can be used when there is no terrain or ground beneath the path..

(img)

#### Disable States

Disable States on the Character while is on the path. E.g. while on the path you can disable the Jump State.

(img)

#### Ignore States

States that will force an early exit on the path. E.g. Jump can force exiting the path if the Jump State is on this list.

(img)

#### Exit Any Mode

If enable, playing any mode will exit the path

#### Ignore Modes

Modes that will force an early exit on the path. E.g. Damage can force exiting the path if the Damage Mode is on this list.

(img)

### Reactions

...

### Events

...


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://malbersanimations.gitbook.io/animal-controller/main-components/path-constraint/mpath.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
