> 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/secondary-components/zones.md).

# Zones

Last updated AC v1.5.3

## Overview

Zones are Triggers that enable logic on the Animal, like Jump, Actions, Deaths... Once an Animal enters a Zone it can be activated via Input or automatically.

<figure><img src="https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2FryXMho9YlZhbemBJrgFg%2Fimage.png?alt=media&#x26;token=21f2aa89-7019-4cc9-9b3c-4b30b76830c3" alt=""><figcaption></figcaption></figure>

The inspector is split into three tabs: **General**, **Events** and **Reactions**.

## Requirements

* A Zone requires any type of **collider** set as **Trigger**.

![](https://963537199-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Lzhr1XSMzMqNXjRnNlb%2F-M5DgBP3I-USn4u6Bzby%2F-M5DhN52jUD5JGFDfxpy%2Fimage.png?alt=media\&token=f62b029f-ba27-4cb7-8c74-400042c21794)

* The Layer set on the GameObject must be different from the Layers set on the [Ground Layer](/animal-controller/main-components/manimal-controller/general.md) in the Animal Controller. Usually it is set as **Ignore Raycast**.

![](https://963537199-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Lzhr1XSMzMqNXjRnNlb%2F-M5DgBP3I-USn4u6Bzby%2F-M5DhZAEILUPebrxvpqy%2Fimage.png?alt=media\&token=27e74b49-1350-4bb2-bf2c-90620aa9c0b1)

{% hint style="danger" %}

### The Animal needs to have any type of collider and a Rigidbody to interact with the Zone

{% endhint %}

## How it Works

1. An Animal enters the trigger. It is checked against **Layer**, **Tags** and **Bone Only**, and stored in the Zone.
2. If **Automatic** is on, the Zone tries to activate right away. Otherwise it waits for a call to `ActivateZone()`.
3. Activation checks, in order: the **Limit**, the [Activation Conditions](#activation-conditions), then the **Angle**. A failure at any step invokes **On Zone Failed** and stops.
4. The logic for the [Zone Type](#zone-type) runs. Only if it reports success is the Animal counted against the **Limit** and **On Zone Active** invoked.

{% hint style="info" %}
A failed activation no longer consumes a **Limit** slot. In earlier versions every failed attempt permanently burned one, so after `Limit` failures the Zone could never be used again.
{% endhint %}

## General

### Automatic

As soon as the Animal enters the Zone it will activate the Zone logic. If set to false you need to manually call `Zone.ActivateZone()`.

### Disable After Used

Disables the Zone after it has been used once.

### Disable Delay

Seconds to wait before the Zone is disabled. Only shown when **Disable After Used** is on. Use it to let an animation or a Reaction finish before the trigger goes away.

### Reset on Active

Removes the stored Animal from the Zone when the Zone is activated, resetting it to its default state.

### Limit

How many characters can use this Zone at the same time. A negative value (`-1`) means no limit.

### Zone ID

ID of the Zone, independent of the Mode/State/Stance ID it drives. It is what the **Animal → In Zone** Condition and the `Zone ID` checks compare against.

### Trigger

Which collider is the trigger for the Zone. Filled automatically with the first collider on the GameObject.

### Debug

The bug icon next to the tabs. In Play Mode the inspector lists the Animals in the Zone, the Animals using the Zone and the colliders inside it, and logs every activation.

## Zone Type

A Zone can modify a [Mode](/animal-controller/main-components/manimal-controller/modes.md), a [State](/animal-controller/main-components/manimal-controller/states.md), a [Stance](/animal-controller/main-components/manimal-controller/stances.md), apply a **Force**, or run **Reactions Only**.

<figure><img src="https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2F3Whq96V1CG6UQIKExlv2%2Fimage.png?alt=media&#x26;token=e04fa971-a626-4d15-9492-713cb72abd73" alt=""><figcaption></figcaption></figure>

## Type: Mode

### Mode ID

Which Mode ID should activate.

### Ability Index

Which Ability should activate. See the [Modes](/animal-controller/main-components/manimal-controller/modes.md) documentation for more information.

{% hint style="info" %}
When the Mode is set to **Action**, the **Ability Index** parameter automatically changes to **Action Index**, so you can pick the [Action ID](/animal-controller/scriptable-architecture/scriptables/scriptable-ids.md) to play on the Animal. The small **•** button next to the Mode ID toggles that field.
{% endhint %}

### Status

How the Mode Ability should be played.

<figure><img src="https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2F6sbmSU7OHPVeKpTUrAJi%2Fimage.png?alt=media&#x26;token=fd6a545b-43ef-4b33-a682-fa2c027032aa" alt=""><figcaption></figcaption></figure>

| Status                     | What it does                                                   |
| -------------------------- | -------------------------------------------------------------- |
| Play Once                  | Plays the Ability once and exits when the animation finishes.  |
| Charged or Hold Input Down | The Ability can be charged while the input is held.            |
| Play for x sec             | The Ability stays on for **Ability Time** seconds.             |
| Toggle                     | The Ability turns on and off every time the Zone is activated. |
| Forever                    | The Ability plays until the Mode is interrupted.               |

### Ability Time

Seconds the Ability stays active. Only shown when **Status** is **Play for x sec**.

### Mode Power

Value assigned to the Mode float value when using the Zone.

### Prepare Mode Zone

When entering a Mode Zone, the **Active Ability Index** of the Animal's Mode is changed to the Zone's Ability Index before the Mode is played. Leave it on unless you want the Animal to keep whatever Ability it already had selected.

### Force Mode

Plays the Mode even when another Mode is already playing.

## Type: State

When the Zone is set to [State](/animal-controller/main-components/manimal-controller/states.md), the Animal will automatically perform a **State Action** when it enters the Zone trigger.

### State ID

ID of the State to modify, e.g. Fly, Death.

<figure><img src="https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2Fnm9uKc26i0aQUGmjudAz%2Fimage.png?alt=media&#x26;token=52fddc8e-197c-458a-94ed-ca84444c2dcc" alt=""><figcaption></figcaption></figure>

### On Enter / On Exit

The Zone can have different actions for entering and exiting. **On Enter** defaults to **Activate**, **On Exit** defaults to **None**.

<figure><img src="https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2FnuFdGVmonWLvhePIR4Zd%2Fimage.png?alt=media&#x26;token=0c8bac50-e415-4742-809e-b7af92132606" alt=""><figcaption></figcaption></figure>

#### Activate

Activate a State on an Animal.

![Horse dies (Activates Death) when it touches the Death Zone Trigger](https://lh6.googleusercontent.com/t6CdKaeHo60lasyeFPHCXDgDqVAHk_okpUn_H60u0XMF4wwP956qBSHRyqn0FiBYsICjIlbhQanh5cTsGdB8LX0I411LAFrWWPv4WDmZAbGTd-MkqRUja9iM2pmZB5DdfrZA_Prj)

#### Allow Exit

Some States cannot exit on their own because some conditions may need to be completed. Calling `State.AllowExit()` on the Animal permits the State to exit and other States with lower priority to try to activate themselves.

For example: a character is Flying, then enters a **Fly State Zone** with **Allow Exit** set. This allows other States like **Fall** to be activated, since the **Fly** State is allowing lower priority States to be active.

![The Dragon Exits Fly when entering the Fly Zone with (AllowExit), allowing Fall State to be activated.](https://963537199-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Lzhr1XSMzMqNXjRnNlb%2F-M5DpwQFEEavm9jNz2nE%2F-M5DssrBidNgGCxfvLj0%2FB1NmLqumLx.gif?alt=media\&token=8e696640-d640-48e2-9f31-39375357bd71)

#### Force Activate

Some States **cannot** be activated on their own because they may require some conditions to be completed. This action forces any State to be active.

E.g. the Swim State can only be activated if the Animal touches water, but it can be forced using this action.

#### Enable

If a State on an Animal is disabled, this enables it back.

E.g. you can have a *Jump State Zone* to enable the **Jump State** when a character exits a room.

#### Disable

Disable a State on an Animal.

E.g. you can have a *Jump State Zone* to disable the **Jump State** when a character enters a room.

#### Set Exit Status

Sets the Exit status on the Animator to the **State Status** value.

#### None

Do nothing. Use it on **On Exit** when leaving the Zone should not undo anything.

### State Status

Status sent to the State on the Animator. `-1` means the Status is ignored. Only shown when the Enter action is **Activate**, **Force Activate** or **Set Exit Status**.

## Type: Stance

When the Zone is set to [Stance](/animal-controller/main-components/manimal-controller/stances.md), the Animal will automatically perform a **Stance Action** when it enters the Zone trigger.

<figure><img src="https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2FkaZ9OK1Pmnv6wiYkmPrF%2Fimage.png?alt=media&#x26;token=54e2009f-f1ae-42e7-999a-2b8d4704a6f6" alt=""><figcaption></figcaption></figure>

### Stance ID

ID of the Stance to modify.

### On Enter / On Exit

The Zone can have different actions for entering and exiting. **On Enter** defaults to **Activate**, **On Exit** defaults to **Exit**.

* **Activate** — the Current Stance on the Animal becomes the Zone's Stance ID.
* **Exit** — the Animal leaves the Zone's Stance and goes back to its Default Stance.
* **None** — do nothing.

### Set Stance as Default

On activation, the Zone's Stance ID also becomes the Animal's **Default Stance**, so the Animal keeps returning to it instead of to its original one.

## Type: Force

<figure><img src="https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2FBwtMmJ2l5JpSzyVFElwx%2Fimage.png?alt=media&#x26;token=3e315d3d-7b0f-4a61-a704-062d3067c9d7" alt=""><figcaption></figcaption></figure>

### Force

Amount of force applied to the Animal.

### Enter Acceleration

Acceleration used to apply the force when the Animal enters the Zone.

### Exit Drag

Drag applied to decrease the force when the Animal exits the Zone.

### Limit Force

Limit for the total amount of force the Animal may accumulate.

### Air Control

Can the Animal be controlled while in the air?

### Grounded

Changes whether the Animal is grounded when entering the Force Zone.

## Type: Reactions Only

The Zone runs **only** its [Activation Reaction](#reactions) on the entering Animal. There is no Mode, State, Stance or Force to configure: the Reaction itself is the whole payload, and the Zone counts as activated when the Reaction reports success.

Use it for Zones that just need to fire a Reaction, such as playing a sound, enabling a component, setting a variable or triggering a Super Item Action, without touching the Animal's State machine.

## Conditions

A foldout inside the **General** tab that gathers every filter deciding **who** can use the Zone and **when**.

### Tags

Set this parameter only if you want the Zone to activate with certain GameObjects carrying Malbers [Tags](/animal-controller/scriptable-architecture/scriptables/tags.md).

### Layer

Which layer should be used to detect the Animal. Defaults to the **Animal** layer.

### Weight

Probability of activating the Zone when entering it, from 0 to 1.\
`0` = 0%, `0.5` = 50%, `1` = 100%.

### Angle

Limits the activation of the Zone to certain entry angles only. `360` (the default) accepts any angle. The arc is drawn as a green gizmo in the Scene view.

### Activation Conditions

Extra [Conditions](/animal-controller/global-components/conditions.md) to check before the Zone activates. The Dynamic Target of the list is the **entering Animal**.

{% hint style="info" %}
Activation Conditions are evaluated **after** the Limit check and **before** the Angle check. A Zone blocked by its Conditions does not invoke **On Zone Failed**.
{% endhint %}

### Double Side

The Zone can be entered from both sides of the angle arc. Only shown when **Angle** is not 360.

### Flip

Flips the direction the angle arc points to. Only shown when **Angle** is not 360.

### Bone Only

Activate only when a specific bone enters the Zone. The bone needs its own collider.

### Bone Name

Name of the bone to check. Only shown when **Bone Only** is on. Default is `Head`.

## Events

On the **Events** tab.

### On Animal Enter Zone

Invoked when the Animal enters the Zone trigger.

### On Animal Exit Zone

Invoked when the Animal exits the Zone trigger.

### On Zone Active

Invoked when the Animal successfully activates the Zone.

### On Zone Failed

Invoked when the Zone fails to activate, e.g. the wrong Animal walked into it or the Limit was reached.

## Reactions

On the **Reactions** tab. Each one is a [Reaction](/animal-controller/main-components/reactions.md) applied on the Animal.

### Activation Reaction

Applied when the Zone activates. For a **Reactions Only** Zone this is the Zone's entire logic, and its result decides whether the Zone counts as activated.

### Enter Reaction

Applied when the Animal enters the trigger, before any activation check.

### Exit Reaction

Applied when the Animal exits the trigger.

`[Insert Image - The Reactions tab of a Zone with the three Reaction slots]`

## Public Methods

See [Public Methods](/animal-controller/secondary-components/zones/pm-zones.md) for the full list. The most used ones:

* `ActivateZone()` — activate the Zone for every Animal currently inside.
* `ActivateZone(MAnimal)` — activate for one Animal, running every check.
* `ForceActivateZone(MAnimal)` — activate for one Animal, skipping the `CanActivateZone` pre-check.
* `RemoveAnimal(MAnimal)` — remove an Animal from the Zone.
* `ResetStoredAnimal(MAnimal)` / `ResetAllAnimals()` — clear the stored Animals.
