> 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

<figure><img src="https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2FwUZVjH5U4Z74SuLw6EWd%2Fimage.png?alt=media&#x26;token=9f429257-946f-4edb-9e26-7d075f4a0464" alt=""><figcaption></figcaption></figure>

The `MPath` component is the bridge between any Path/Spline solution and the Path Constraint. It reads the values it needs from the spline and exposes them so a character wearing a Path Constraint can be aligned to and moved along it.

## How it Works

Every `Path Constraint` in the scene polls all active `MPath` components on its own **Search Interval** and runs a two-phase proximity check: a cheap bounding-box rejection first, then an exact nearest-point-on-spline test. When both the character's `Radius` and this path's `Search Radius` search spheres intersect — and `Automatic` is enabled — the character is constrained to the path.

{% hint style="info" %}
**No Collider required.** Path detection used to rely on a trigger Collider on the path (Box Collider recommended) with a Layer filter. It is now fully code-driven and polled from the character side — if you're migrating an older project you can safely remove the Box Collider, Path Bounds and Layer setup, they no longer do anything.
{% endhint %}

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

## Requirements

* Any type of `IPath` component — [Path Link (Unity Spline)](/animal-controller/main-components/path-constraint/path-link-unity-spline.md) (default) or [Path Link (Straight)](/animal-controller/main-components/path-constraint/path-link-straight.md) for a simple two-point line

{% hint style="info" %}
The Cinemachine Path and Path Creator (Sebastian Lague) integrations have been removed. **Path Link (Unity Spline)**, built on Unity's native Splines package, is now the default. If an older project used either of the removed integrations, switch it to Path Link (Unity Spline).
{% endhint %}

## Parameters

### Path

<figure><img src="https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2Fky73T8dyoZSez9ynfVPB%2Fimage.png?alt=media&#x26;token=609e36b7-c41d-4c73-b3a8-d44104ab4030" alt=""><figcaption></figcaption></figure>

#### IPath

Type of path solution to use — [Path Link (Unity Spline)](/animal-controller/main-components/path-constraint/path-link-unity-spline.md) (default, uses Unity's built-in Spline system) or [Path Link (Straight)](/animal-controller/main-components/path-constraint/path-link-straight.md) for a simple two-point line. Add your solution component to the same GameObject, then hit the refresh button.

<figure><img src="https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2Fle1tj1AAqhgKHtp4JjYV%2FUnity_sB4KpA0chf.gif?alt=media&#x26;token=8ddffbf3-a653-4a51-a566-87a1d065627b" alt=""><figcaption></figcaption></figure>

#### Automatic

The character is constrained to the path automatically as soon as both search spheres intersect.

<figure><img src="https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2FkNMZZ5zkXli5Kj4PE0XG%2FUnity_2aWDEZWfQq.gif?alt=media&#x26;token=08a7f532-2faa-4dab-b453-2e16aaf26945" alt=""><figcaption></figcaption></figure>

Some paths are set to not be Automatic. To activate those, go to the character's Path Constraint component, add an Input connection, and use the method **`TryEnterExitPath()`**. This also works for exiting a path in the middle of it.

<figure><img src="https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2FPElTe7LUwBA2zkmfQlpF%2Fimage.png?alt=media&#x26;token=b6a83378-5384-4bf0-9e89-6aa043e8a7d8" alt=""><figcaption></figcaption></figure>

#### Auto Change Path

Lets the character switch directly from one path onto this one automatically while already constrained to another path. This path also needs `Automatic` enabled.

<figure><img src="https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2FBhtZsOZ5Xwp2Hq3gErn5%2FUnity_PXRT4Q7D2q.gif?alt=media&#x26;token=d7ecb595-b82c-4aa3-ac48-864d9395d8b3" alt=""><figcaption></figcaption></figure>

#### Lock Rotation

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

<figure><img src="https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2FQeFITowpyBbPUqAulcwE%2FUnity_Dsupu9MGGW.gif?alt=media&#x26;token=68aaffec-9ca2-47b5-a869-6d08a5e76132" alt=""><figcaption></figcaption></figure>

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

<figure><img src="https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2FdAi6Qq9p2XbHu60ofHNB%2Fimage.png?alt=media&#x26;token=22dc4bbf-0931-4b0a-b5a3-381e1beaa283" alt=""><figcaption></figcaption></figure>

When Lock Rotation is true you can set the Follow Direction, which automatically rotates the character to match the correct orientation while on the path.

* **None**: the character keeps the starting orientation it had when entering, whether it entered from the start or the end of the spline.

|                                                                                                       Entering from End                                                                                                       |                                                                                                      Entering from Start                                                                                                      |
| :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: |
| ![](https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2FoyopIvisdFrGZSa2hnte%2FUnity_HAGOGvOSth.gif?alt=media\&token=59bd7cdb-862d-404f-a06f-93d176ffd4ee) | ![](https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2F7o9wBPdvvQXpvtWNid6E%2FUnity_VHT9Yfs5mU.gif?alt=media\&token=f557d621-21c7-44a6-9d3e-260fc5bea69b) |

* **Forward**: the character is oriented to the forward path direction (start to end), regardless of which end it entered from.

|                                                                                                       Entering from End                                                                                                       |                                                                                                      Entering from Start                                                                                                      |
| :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: |
| ![](https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2F9FSSQwhjgAI7vg0kJjlM%2FUnity_ULHBvYBPCs.gif?alt=media\&token=e2d306ab-0635-4c72-99d2-db21fbfb6829) | ![](https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2F7o9wBPdvvQXpvtWNid6E%2FUnity_VHT9Yfs5mU.gif?alt=media\&token=f557d621-21c7-44a6-9d3e-260fc5bea69b) |

* **Backward**: the character is oriented to the backward path direction (end to start), regardless of which end it entered from.

|                                                                                                       Entering from End                                                                                                       |                                                                                                      Entering from Start                                                                                                      |
| :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: |
| ![](https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2FoyopIvisdFrGZSa2hnte%2FUnity_HAGOGvOSth.gif?alt=media\&token=59bd7cdb-862d-404f-a06f-93d176ffd4ee) | ![](https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2FVV1prepdkVU7DjK3fvaK%2FUnity_5bJExEfN9I.gif?alt=media\&token=c9c5cad5-3256-46c8-b581-39eb84687c06) |

#### Use Path Rotation

The character also follows the path's own rotation values (banking, pitch, and similar orientation baked into the spline), not just its position.

<figure><img src="https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2FwJVfwGYUmMBC0uzkf7sp%2FUnity_DuJIc90F0h.gif?alt=media&#x26;token=37ec8b75-dcf8-4238-939d-129d2ae9f756" alt=""><figcaption></figcaption></figure>

#### Orient Smoothness

Per-path multiplier for how fast the character orients to this specific path (multiplies the Path Constraint's own **Orient Smoothness**). Use it to make some paths (e.g. tight rails) snap the character into orientation faster than others.

#### Alignment Offset

Local offset applied to the character's position while it's constrained to this path.

#### Path Position

Optional Transform that is kept updated to the character's current position and rotation on the path — use it to have another GameObject follow along the ride.

<figure><img src="https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2FXarMHmEnii6XLa0gxCYt%2Fimage.png?alt=media&#x26;token=716aa322-a733-4e4f-b2f7-efa9a3403dd5" alt=""><figcaption></figcaption></figure>

#### Can Exit on Start

The character can exit automatically when it reaches the start of the spline.

#### Can Exit on End

The character can exit automatically when it reaches the end of the spline.

#### Can Exit on Middle

The character can exit if something interrupts the path mid-way (e.g. jumping off in the middle of the spline).

<figure><img src="https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2FHKahIP8QyfuKwyDiE5Mv%2Fimage.png?alt=media&#x26;token=e7f10f46-6113-4b8a-9621-d41df2e995cf" alt=""><figcaption></figcaption></figure>

#### No Exit Path Reactions

If this path is entered while the character is already on another path, skip that old path's Exit reactions (**Exit Reaction**, **Exit From Start/End/Middle**). Useful for seamless path-to-path transitions where you don't want the "leaving" reaction to play.

#### Path Cooldown

Once the character enters this path, this much time must elapse before it can exit and re-enter it again. Prevents flicker from entering and exiting on the same frame.

#### Search Radius

Radius of this path's own search sphere. When it intersects the character's `Radius`, the character can enter.

#### Search Offset

Offset of the search sphere relative to the path's position.

<figure><img src="https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2FXLxNnUG48uiulMd18Lto%2FUnity_5hnQeZi8Gi.gif?alt=media&#x26;token=46a581a4-4c27-4831-ba72-3e2a5b8b3204" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
Looking for the search **interval**? It now lives on the character's Path Constraint component, since the search is polled by the character, not the path.
{% endhint %}

### Animal

<figure><img src="https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2FsDqSsJNtlYn624rngJcS%2Fimage.png?alt=media&#x26;token=f95cc29d-9372-40b6-ba9b-5864d8bb18b5" alt=""><figcaption></figcaption></figure>

#### Activate State

State to activate when the character enters this path.

#### Ignore Vertical

While active, the animal cannot move on the Y-axis while on the path. Disable this if you want the character to be able to jump while on the path.

\[Insert Image - Ignore Vertical enabled vs disabled]

#### Ignore Grounded

Use when there's no terrain/ground beneath the path (e.g. a rope bridge or zip line over a chasm) so the animal doesn't fight grounding checks.

\[Insert Image - Ignore Grounded on an elevated path]

#### Disable States

States disabled on the character while it's on the path. E.g. disable the Jump State while riding a rail.

\[Insert Image - Disable States list on a path]

#### Ignore States

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

\[Insert Image - Ignore States list on a path]

#### Exit Any Mode

If enabled, playing any Mode exits the path.

#### Ignore Modes

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

\[Insert Image - Ignore Modes list on a path]

### Reactions

Reactions are played on the character (`Reaction2`, through the `MAnimal`) as it enters and exits the path.

#### Enter Reaction

Always plays when the character enters the path, in addition to the matching Enter From Start/End/Middle reaction below.

#### Exit Reaction

Always plays when the character exits the path, in addition to the matching Exit From Start/End/Middle reaction below — unless the path being entered next has `No Exit Path Reactions` enabled.

#### Enter From Start / Enter From End / Enter From Middle

Plays depending on where along the spline the character entered from.

#### Exit From Start / Exit From End / Exit From Middle

Plays depending on where along the spline the character was when it exited.

### Events

#### Can Enter Path

Raised per-character when `Automatic` is disabled and that character is close enough to enter manually — call `TryEnterExitPath()` on its Path Constraint while this is `true` to enter. Lowers back to `false` once the character enters or walks away.

#### On Enter Path / On Exit Path

Invoked when a character enters/exits this path. Passes the character's `Path Constraint` component.

#### Is On Start Of Path / Is On End Of Path

Raised `true` once the character gets within tolerance of the path's start/end (before it actually exits), and back to `false` once it moves away from that end again. Useful to trigger slow-down or warning behavior near the ends of a path.
