> 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.md).

# Path Constraint

## Overview

<figure><img src="https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2FjU4DFizSTWOpp098K719%2Fimage.png?alt=media&#x26;token=d3671e4e-a8f5-4023-8370-99d12c6de566" alt=""><figcaption></figcaption></figure>

This component allows the character to travel on a path. It is the connection between a [Path](/animal-controller/main-components/path-constraint/mpath.md) and the Animal Controller — add it to the character and it takes care of finding nearby paths, aligning the character to them, and driving movement while active.

{% hint style="info" %}
**Detection is fully character-driven.** `Path Constraint` polls every active `Path` in the scene at **Search Interval** and tests for proximity. No Collider or trigger setup is required on either component — if you're migrating an older project, any Box Collider you had for this can be removed.
{% endhint %}

## Requirements

It requires a reference to the `Animal` component. If left empty, it is found automatically on `Awake`/`Reset`.

## How it Works

<figure><img src="https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2FDQYrfAKvP3it32LkDujD%2Fimage.png?alt=media&#x26;token=317ba212-86c9-410d-81bd-51da635017e0" alt=""><figcaption></figcaption></figure>

With the component added to your character, when you get close enough to any `Path` the character enters the nearest one automatically and Path Constraint takes over alignment and movement. All the properties that control the animal *while* it's on the path are set on the [Path](/animal-controller/main-components/path-constraint/mpath.md) component itself — Path Constraint only controls how the character searches for and blends into paths.

As a recommendation, set the Path Constraint inside the Animal Controller's internal components, as a child GameObject.

Some paths are not set to `Automatic`. To enter/exit those manually, wire an Input to the method **`TryEnterExitPath()`**.

<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>

This also works to exit a path in the middle of it, as long as the Path has `Can Exit on Middle` enabled.

## Parameters

#### Animal

Reference to the Animal Component.

#### Path

Current active Path this constraint is on. Read-only at runtime — you can assign a starting Path here in the Inspector if the character should already be on a path when the scene starts.

#### Auto Move

It will move the character automatically while it's on a path — no movement Input needed. Useful for conveyor belts, zip lines, cutscene rails, and similar always-moving paths.

\[Insert Image - Auto Move driving the character along the path with no input]

### Interactions

<figure><img src="https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2FXrtltjXZsudfm9mEi9Yl%2Fimage.png?alt=media&#x26;token=048a0c3a-6324-4d2b-83e4-aca8040cb42d" alt=""><figcaption></figcaption></figure>

#### Forward Offset

Forward point used to calculate the path direction. Keep this value small — it's used to detect hard turns in the path.

#### Radius

Radius of the character's search sphere. When it intersects a Path's own search sphere, the character can enter that path.

#### Offset

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

<figure><img src="https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2FkP6O5CowAKak0RIMh7lD%2FUnity_7yDwYpEgLX.gif?alt=media&#x26;token=bedc1a9c-e533-4a39-9393-a52ddecb7e9b" alt=""><figcaption></figcaption></figure>

#### Search Interval

How often (in seconds) the character scans nearby paths for a possible entry. `0` searches every frame — increase this value to save performance, decrease it for more responsive entries.

|                                                                                                     Search Interval = 0.5f                                                                                                    |                                                                                                      Search Interval = 0f                                                                                                     |
| :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: |
| ![](https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2FytuuvZcgNTM97in0yErj%2FUnity_AtDLKiMnyI.gif?alt=media\&token=4d22ae47-6707-4743-b304-80ba9996a8f8) | ![](https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2FWQEuE1J3ugaiQYvd2Nz0%2FUnity_rk0u0dR4V0.gif?alt=media\&token=91eabdcc-fb76-4b33-a6f5-719885c8833f) |

### Alignment

#### Orient Smoothness

Lerp speed to orient the character to the path. The higher the value, the faster the character orients to the path.

#### Align Smoothness

Lerp speed to position the character onto the path. The higher the value, the faster the character snaps onto the path.

## Events

<figure><img src="https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2FCRnyMOLsyj8ebFmJy4gd%2Fimage.png?alt=media&#x26;token=ae4f1546-7bf1-4746-a14a-122f11243db6" alt=""><figcaption></figcaption></figure>

#### On Enter Path

Invoked when the character enters a Path. Passes the entered Path's GameObject.

#### On Exit Path

Invoked when the character exits a Path. Passes the exited Path's GameObject.
