# Locomotion

## Overview

The Locomotion State [**ID** ](../../../../scriptable-architecture/scriptables/scriptable-ids#states-ids)is **1.** It allows the animal to move while it's on any ground surface

## How it works

When the character moves it uses the `MAnimal.Move(Vector 3 Direction)`method, this will activate the locomotion animations.

## Creating the State

To create a new Locomotion State, click the Plus button on the States list and select: \[Locomotion]

Or duplicate any of the already created locomotion assets of any animal you own and drag it to the States List.

![](https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2Fwtc9zTlp4g8exaslJSTk%2Fimage.png?alt=media\&token=b991e590-cae5-449a-87db-a09e3316a36a)

## Priority

Locomotion should always be on top of the Idle and below all other assets.&#x20;

<figure><img src="https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2F0DVmTe8W8gwWD3wkpSFt%2Fimage.png?alt=media&#x26;token=d102f9ed-d0bf-48c3-9d09-3b3e60b76ddf" alt=""><figcaption></figcaption></figure>

## Requirement

The Idle State does not require extra gameobjects, pivots, or internal animal configuration. Just an animation or animations to be used as Idles.

## Activation Condition

* The Animal has detected any movement. (Movement Detected = true)
* The Animal is grounded. (Grounded  = true)

You can always Force its activation via code.

**`Animal.State_Force(1)`  or  `Animal.State_Force(StateEnum.1)`**

## Exit Conditions

Through code, the exit conditions will be executed to check if the State can exit. In the case of this state, the **conditions** are:

* The Animal has **NOT** detected any movement. (Movement Detected = false)

## Animator

### Locomotion Sub-State Machine

The Sub-State Machine \[Locomotion] will hold all the Locomotion Animations.

Its entering transition conditions are:

<figure><img src="https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2FEsWnZUAzLL9uILYPjYfY%2Fimage.png?alt=media&#x26;token=4c14aea0-d634-49fa-9b06-ec505d4426c5" alt=""><figcaption></figcaption></figure>

### Core Animations

All States have a core animation, on which the animal will play while the state is active. In the case of locomotion, a blend tree is required with all the speeds the character may have,

<figure><img src="https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2FapCoM3o1oD3CbxqnwKoz%2FUnity_H9HwZVPF7o.gif?alt=media&#x26;token=4e4d7825-9cdd-4ed9-9319-53dcf1957127" alt=""><figcaption></figcaption></figure>

The core animations must be always tagged just like the Name of the State ID.&#x20;

<figure><img src="https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2FOZboAYvdOpAqLC2UKvsH%2Fimage.png?alt=media&#x26;token=5ac9eb91-dbb1-4f63-93d0-e682287e813f" alt=""><figcaption></figcaption></figure>

The multiplier parameter is linked to the SpeedMultiplier. This handles the speed of the animation with the **Speed Modifiers.**

### Exit Condition

The Locomotion will exit only when there is no movement registered.



## Locomotion Features

<figure><img src="https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2FTQP4dmccz8kqkeJVK7cK%2Fimage.png?alt=media&#x26;token=c43bd8a5-b07c-47a2-bb2e-36be144da5d7" alt="" width="563"><figcaption></figcaption></figure>

### Fall Ray Backwards

### Reset Inertia

### Wall Stop

#### Stop Layer:

Layer used in the raycast to check front Walls and stop the character from moving.

#### Wall Stop Properties

{% embed url="https://streamable.com/y2ar58" %}

### Anti Fall

Antifall allows the animal to avoid ledges. This is used mainly for huge animals that does not have the Fall State and it should avoid falling from edges at all times. E.g. The elephant

### Locomotion Start Tag

When you set a new Tag and Use it on the Enter Tag Parameter, the **Vertical parameter on the animator** will be set with no smoothness to the Speed Vertical value. E.g. If we are entering from Idle To locomotion in a Run Speed, the Vertical will be set to 3 directly. This is used to play IdleToRun animations correctly.

<figure><img src="https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2FYfr2wtYsbaC9EemGljPd%2Fimage.png?alt=media&#x26;token=27c81f54-7d08-487b-ad0e-8841d80e4d7e" alt=""><figcaption></figcaption></figure>







