> 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/manimal-controller/states.md).

# States

Last updated AC v1.5.3

## Overview

States are the core logic for the Animal to work. They make the Animal move, fall, jump, die, etc.

States are animations that do not overlap each other. For example: the Animal cannot be running and jumping at the same time, or flying and swimming.

They are also sorted by **priority**, meaning that higher priority States will try to activate first, followed by the lower priority ones.

<figure><img src="https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2FG3MJh5nvGpNp0BPBxUN3%2Fimage.png?alt=media&#x26;token=b342e16b-46c8-4ead-9e50-8c970631884e" alt="" width="467"><figcaption></figcaption></figure>

{% hint style="info" %}
If a higher priority State is the **Active** State, lower States won't try to activate unless the Active State allows it. Using **`State.AllowExit()`** will give the lower States a chance to activate themselves again.

That is why when the Animal is in the Fly State, all the lower States like Fall, Swim or Jump won't be activated unless the Fly State's **AllowExit()** is called.
{% endhint %}

A State asset's inspector is split into five tabs: **General**, **Tags**, **Limits**, **Speeds**, and a last tab named after the State itself, which holds that State's own parameters.

## Override Start State

Starts the Animal Controller in a custom State instead of initializing in \[Idle].

If you want the Animal to start with the **Fly State** then set the **Fly ID** there.

<figure><img src="https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2FhZd3Y51uTd9LJ3CKvoov%2FUnity_GO7qcQysrm.gif?alt=media&#x26;token=fd4aea2b-5c87-492a-9620-71f9ae618695" alt=""><figcaption></figcaption></figure>

## Clone States

<figure><img src="https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2Fd6msSb2UvHTnuOyHePxH%2Fimage.png?alt=media&#x26;token=279e0d02-21a0-4aa2-8d17-cdfc8223e947" alt=""><figcaption></figcaption></figure>

This option will clone all the State ScriptableObject assets at runtime. That way all the Animals will have unique States.

{% hint style="success" %}
If you are using an Animal as your Main Player, you can deactivate the **Clone States** option and modify internal values directly on the assets.
{% endhint %}

All States share common parameters, which make it easier to change properties on the Animal Controller while the core animation of the State is playing, or when a new State or Mode is activated.

## Animator

All States require at least one Animation State in the Animator, even if you don't need one. You can always create an empty Animation State or reuse an existing animation clip.

## General

<figure><img src="https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2FU67aTII8gWRga4dObgkL%2Fimage.png?alt=media&#x26;token=50cd53e3-2593-4a1d-b719-0e103eee02d7" alt=""><figcaption></figcaption></figure>

### ID

Unique [ID](/animal-controller/scriptable-architecture/scriptables/scriptable-ids.md) for the State that helps identify every State. These are added automatically when a State is created.

![](https://963537199-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Lzhr1XSMzMqNXjRnNlb%2F-M-jWXW-c86xrpz7o6J8%2F-M-jbv1L7WcvgcvO_j7B%2FXZ5bSKQvjO.gif?alt=media\&token=f61c97fa-4e89-4933-861e-e4f3304da21a)

{% hint style="warning" %}

### IMPORTANT

The name of the State (e.g. \[**Death]**) is used and **MUST BE SET** as the **Main Tag** for the main animations of that State, otherwise the controller won't work properly.
{% endhint %}

![](https://963537199-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Lzhr1XSMzMqNXjRnNlb%2F-M-jcZDDAKrB0qcfO-g5%2F-M-jd-B9drVbKbYU2b7-%2Fimage.png?alt=media\&token=71595aa3-2059-4a7b-bba4-994516aece0b)

### Debug

The bug icon next to the ID. In Play Mode it shows a live readout of the State: Priority, Enabled, Is Active State, Can Exit, On Queue, Pending, Sleep From State/Mode/Stance, In Core Animation, Ignore Lower States, Is Persistent, On Hold by Reset and both Input values. Each State also enables its own gizmos and logs while Debug is on.

### State Profile

Allows different ways of using a State, setting different values for the same type of State. E.g. if you had 2 flying profiles set up, one could be flying as Iron Man, and the other could be flying using a broom.

### Priority

Priority of the State. Higher value -> higher chance to be activated.

This value is set automatically by the Animal Controller for each State. It is edited on the **State list of the Animal**, not on the State asset itself:

<figure><img src="https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2FG3MJh5nvGpNp0BPBxUN3%2Fimage.png?alt=media&#x26;token=b342e16b-46c8-4ead-9e50-8c970631884e" alt="" width="467"><figcaption></figcaption></figure>

### Enter Input

Input to activate the State. This parameter is completely optional, since some States activate automatically, like Swim (when the Animal is near water) or Fall (when there's no ground beneath the Animal).

{% hint style="info" %}
Match the **Input** with the Input Item Name on any of the Malbers Input Components.
{% endhint %}

![The name of the Input \[Jump\] matches with Malbers Input Jump slot](https://963537199-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Lzhr1XSMzMqNXjRnNlb%2F-McjL12xXQypP22mMo4i%2F-McjLbUYFJMZ_tCm_hzG%2Fimage.png?alt=media\&token=952a4bf0-d313-45ee-9894-a77347c0582f)

![](https://963537199-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Lzhr1XSMzMqNXjRnNlb%2F-M-jdO07Vr-zREYvmBHc%2F-M-jebUt2q2OsGDxA4fe%2Fimage.png?alt=media\&token=58a7f518-d097-462c-85fa-87269fe2a0d6)

{% hint style="info" %}
There are States that do **not** require Inputs to be activated. They are activated internally using the `TryActivate()` method.

Here are a few examples:

* Idle -> Movement Vector is Vector3.Zero.
* Locomotion -> Movement Vector is NOT Vector3.Zero.
* Fall -> There's no ground beneath the Animal.
* Swim -> The Animal is inside a Trigger with Layer: Water.
  {% endhint %}

You can also activate any State using **`MAnimal.State_Activate(StateID state)`**, just like the Health Stat activates the Death State when Health is empty. (Check it on the Stats component -> Health Stat.)

![](https://963537199-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Lzhr1XSMzMqNXjRnNlb%2F-McjL12xXQypP22mMo4i%2F-McjNk4ICrRMWd4mTBZr%2Fimage.png?alt=media\&token=16a23fa8-1fb3-42de-9d68-13c92391b055)

### Exit Input

States can be allowed to exit if there's an Input connected to this parameter.

![The Climb State can exit if the Crouch Key is pressed (See Steve)](https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2Fc5wWbSWCjOpvVMNh2jEN%2Fimage.png?alt=media\&token=122b1977-1a11-4165-9fff-0765b5eb2a1f)

### Enter Input Value / Exit Input Value

The live boolean value of each Input. They are exposed as Bool References so they can be driven by a Scriptable Variable instead of an Input component, which is how AI characters and cutscenes trigger input-driven States without any input at all.

### Reset Input on Failed

If the State is trying to be activated by an Input and it fails for whatever reason (check the debug logs for more info) then the Input value is reset.

### Override Capsule

When the State is playing it overrides the Animal's main Capsule Collider to fit the State better, e.g. a shorter capsule while crawling or sliding. Turning it on reveals the **New Capsule** values (height, radius, centre).

### Always Forward

Mark this as true if you want the character to only be able to go forward in this State, e.g. endless runner type of games.

### Reset Last State

When entering this State, the **Last State** Animator parameter will be reset to `-1`.

### Allow Exit From Anims

To allow the State to exit, the animations need to use the **\[Allow Exit Behaviour]** on the Animator.

This is used when States require exit animations and they should not exit from the main animation state.

![Climb State requires Exit Animations](https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2FUG2ZhQX6v2yL4wsXX0PK%2FUnity_UVCoAVuIsF.gif?alt=media\&token=070b5bf7-daea-4042-8d9e-48930702df12)

### Can Transition to Itself

The State can be activated even when it's already the current State, e.g. if you are trying to do double/triple jumps.

### Exit on Main

Set to true to try to exit the State on the main State animation. E.g. the Falling animation can try to exit only when on the Fall animation.

### Enter Cooldown

Time needed to activate this State again after exiting.

### Exit Cooldown

Time needed to exit this State after being activated.

### Try Loop

Try States will try to activate every X frames.

### Duration

Keeps the State enabled for X seconds, after which it will execute the internal `AllowExit()` State method. If it's set to 0, this is ignored.

### Can Strafe

Allows the character to strafe in this State. The three fields below are only shown when it is on.

### Strafe Animations

This State has its own strafe animations. If set to false, it will not update the Animator with the \[StateOn] parameter.

### Movement Strafe

Strafe multiplier when movement is detected. Higher values align the character to the strafe direction more quickly.

### Idle Strafe

Strafe multiplier when there is no movement. Higher values align the character to the strafe direction more quickly.

### Remove Force on Enter

When entering this State, any external force applied to the Animal is removed. Turning it on reveals **Force Damping**, which controls how quickly that force is drained instead of being cut instantly.

## Tags

The Tags Modifier property changes main features on the Animal Controller once the State enters the MAIN animations on the Animator Controller. The core tag value is the name of the State ID.

E.g. when the Animal enters the MAIN **Fall** animation on the **Fall** State we need:

<figure><img src="https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2FZbFhGQ8Ea8PKmERUiryP%2Fimage.png?alt=media&#x26;token=6ff58e4c-afc0-43a3-a0f4-88700391fe1a" alt=""><figcaption></figcaption></figure>

* Root Motion and Sprint to be disabled.
* Gravity enabled.
* The Animal to **NOT** be Grounded or using a Custom Rotation.
* Ignore Lower States disabled (which allows lower priority States to be activated if they can).
* Additional Positional Speed enabled.

{% hint style="info" %}

## Find out here what every [Animal Modifier](/animal-controller/main-components/manimal-controller/animal-modifiers.md) does.

{% endhint %}

### Enter Tag

Animator Tag to identify entering animations on a State, e.g. 'TakeOff' in Fly, 'EnterWater' in Swim.

<figure><img src="https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2FbS2yUqqq08VIuaHX0Sph%2Fimage.png?alt=media&#x26;token=25996d53-3320-4462-b2bd-1ec220191c83" alt=""><figcaption></figcaption></figure>

### Exit Tag

Animator Tag to identify exiting animations on a State, e.g. 'Land' in Fall or 'SwimClimb' in Swim.

## Messages

When in the State, you can set up messages to send to the Animal's components.

### Use SendMsg

When sending messages, if toggled true it will use Unity's built-in `SendMessage` instead of the `IAnimatorListener` interface.

### Children

When sending messages, it will send them to all the Animal's child GameObjects.

## Animation Tags (additional modifiers)

<figure><img src="https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2FEPPfUmPZtwvhoNAbtceO%2Fimage.png?alt=media&#x26;token=236124e2-464d-4765-ab17-99e1db242604" alt=""><figcaption></figcaption></figure>

Use this section to set up additional modifiers for specific animations inside the State, e.g. FallEdge or Landing in the Fall State, when you want those animations to have slightly different modifiers.

## Limits

<figure><img src="https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2FGTktzWSjsSYveNHrPEMB%2Fimage.png?alt=media&#x26;token=12b0a7ea-0ba6-4406-a2bc-fa679fe06e17" alt=""><figcaption></figcaption></figure>

Limits allow you to set limitations on the State when another State, Mode or Stance is playing.

{% hint style="info" %}
Every list on this tab is an **ID List** with an **Include / Exclude** switch. **Include** (the default) means "the listed IDs". **Exclude** inverts it, so the rule applies to **everything except** the listed IDs. An empty Exclude list therefore matches everything.
{% endhint %}

### Sleep From State

If the Active State is one on the list, this State can't be activated.

{% hint style="info" %}
E.g. the [Jump](/animal-controller/main-components/manimal-controller/states/jump.md) State is set to Sleep when the Animal is in the [Fall](/animal-controller/main-components/manimal-controller/states/fall.md), [Fly](/animal-controller/main-components/manimal-controller/states/fly.md), or [UnderWater](/animal-controller/main-components/manimal-controller/states/underwater.md) State.
{% endhint %}

![](https://963537199-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Lzhr1XSMzMqNXjRnNlb%2F-M-lrvbrcXCfcYJnl6Qk%2F-M-lvtmCbqLR7Iwg5MfC%2Fimage.png?alt=media\&token=04b20c20-2c11-4f30-8340-c44ab300a3bc)

![Check the State List: The Jump State that is set to \[Sleep\] while on Fall or Fly](https://963537199-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Lzhr1XSMzMqNXjRnNlb%2F-M-lrvbrcXCfcYJnl6Qk%2F-M-lv49Ya5dl7YE4JLmn%2FmnBc4cf01r.gif?alt=media\&token=ae8db9c9-0752-4f87-861f-89b235e0c5e1)

### Queue From

If the Active State is on the queue list, this State will be queued until the Animal exits the Active State.

E.g. the Death State will be queued if the Animal is in the Fall State, and will be activated once the Fall State finishes.

### Reset From

If the State exits, it cannot be used again until one of the States on this list gets activated. E.g. you can disable Fly and not use it again until the character uses Idle or Locomotion.

### Modes

#### Sleep From Mode

If a Mode is playing (e.g. Attack, Action) you can send this State to sleep using this list. E.g. the Animal cannot Jump while attacking.

![Check the State List: The Jump State that is set to \[SleepM\] while an Attack is Playing](https://963537199-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Lzhr1XSMzMqNXjRnNlb%2F-MWQsR__sKiTzm6vIy2D%2F-MWQuLONjbNL2FscACDf%2FaQPpuRcVXd.gif?alt=media\&token=0de6c875-2dfc-40f6-9fe6-ea45caee3d79)

#### No Modes

Do not allow **any** Mode while this State is active. Every Mode is internally disabled. Turning it on hides **Disable Modes**, since it already covers all of them.

#### Disable Modes

While this State is active, disable only the [Modes](/animal-controller/main-components/manimal-controller/modes.md) on this list. They are re-enabled when the State exits.

{% hint style="info" %}
**Sleep From Mode** blocks *this State* while a Mode is playing. **Disable Modes** works the other way around: it blocks *those Modes* while this State is active.
{% endhint %}

### Stances

#### Sleep From Stance

If a [Stance](/animal-controller/main-components/manimal-controller/stances.md) on this list is active, this State cannot be activated. E.g. while in the balance Stance for walking across a tightrope, you cannot Jump.

#### Allowed Stances

Which Stances are allowed during this State. Leave it empty to allow all of them.

## Speeds

A State can carry its own [Speed Sets](/animal-controller/main-components/manimal-controller/speeds.md) instead of using the Animal's. Each Set holds the Speed Modifiers (Walk, Trot, Run, Sprint...) used while the State is active, with their Animator, Position, Rotation, Lerp and Sprint values.

Use it for States whose movement has nothing to do with ground locomotion, like Fly, Swim or Climb.

`[Insert Image - The Speeds tab of a State with a Speed Set expanded]`

## State Parameters

The last tab is named after the State and holds that State's own parameters — the Fly State's lift and drag, the Climb State's ray distances, and so on. See each State's page for those.

Two fields on this tab are shared by every State:

### Enter Conditions

Extra [Conditions](/animal-controller/global-components/conditions.md) that must be true for the State to activate. The Dynamic Target of the list is the **MAnimal** component. They are evaluated on top of the State's own activation logic, so a State that could not activate anyway stays inactive.

### Exit Conditions

When these [Conditions](/animal-controller/global-components/conditions.md) become true, **Persistent** and **Ignore Lower States** are set to false, allowing other States to be activated. The Dynamic Target is the **MAnimal** component.

### Pause On Activate

Pauses the Editor when the State activates. An authoring aid for catching a one-frame activation, not something to ship.

## All included States so far

#### [Idle](/animal-controller/main-components/manimal-controller/states/idle.md) | [Locomotion](/animal-controller/main-components/manimal-controller/states/locomotion.md) | [Fall](/animal-controller/main-components/manimal-controller/states/fall.md) | [Basic Jump](/animal-controller/main-components/manimal-controller/states/jump-basic.md) | [Root Motion Jump](/animal-controller/main-components/manimal-controller/states/jump.md) | [Swim](/animal-controller/main-components/manimal-controller/states/swim.md) | [UnderWater](/animal-controller/main-components/manimal-controller/states/underwater.md) | [Climb](/animal-controller/main-components/manimal-controller/states/climb.md) | [Ledge Grab](/animal-controller/main-components/manimal-controller/states/ledge-grab.md) | [Fly](/animal-controller/main-components/manimal-controller/states/fly.md) | [Glide](/animal-controller/main-components/manimal-controller/states/glide.md) | [Wall Run](/animal-controller/main-components/manimal-controller/states/wall-run.md) | [Wall Run Vertical](/animal-controller/main-components/manimal-controller/states/wall-run-vertical.md) | [Slide](/animal-controller/main-components/manimal-controller/states/slide.md) | [Rail Grind](/animal-controller/main-components/manimal-controller/states/rail-grind.md) | [Death](/animal-controller/main-components/manimal-controller/states/death.md) | [Death Ragdoll](/animal-controller/main-components/manimal-controller/states/death-ragdoll.md)

{% hint style="info" %}
Want your own? See [Creating a new State](/animal-controller/main-components/manimal-controller/states/creating-a-new-state.md). More States will be added in the future with the addition of new Animals :grin:
{% endhint %}
