# Fly

## Overview

The Fly State allows the animal to fly and glide. Its State [**ID** ](/animal-controller/scriptable-architecture/scriptables/scriptable-ids.md#states-ids)is **6.**&#x20;

![](/files/-MWS3CE2YidKspA4L2U_)

## Creating the Fly State

To create a new Fly State Click the Plus button on the States list

![](/files/-M3Ml29QCbxIev4MblHA)

Or just duplicate any of the already created Fly States Assets of any animal you own and drag it to the States List.

## Priority

The state should have a higher priority than [**Idle**](/animal-controller/main-components/manimal-controller/states/idle.md), [**Locomotion** ](/animal-controller/main-components/manimal-controller/states/locomotion.md)and [**Fall**](/animal-controller/main-components/manimal-controller/states/fall.md). but below [**Death**](/animal-controller/main-components/manimal-controller/states/death.md) since the animal can be killed any time.

<figure><img src="/files/Y0tpajl7YwZ53xSZHPSS" alt=""><figcaption></figcaption></figure>

When the animal is on the this state, all the Lower priorities states are ignored until the[ **exit conditions**](/animal-controller/main-components/manimal-controller/states/fly.md#exit-conditions) for this state are fulfilled.&#x20;

## Requirements

### Rotator

The State **requires** an Empty Transform set as a [**Rotator**](/animal-controller/main-components/manimal-controller/advanced.md)**.** This Rotator is the pivot of the Pitch rotation of the animal while flying.

<figure><img src="/files/DRrHkPInjdMiTQ8wGHbQ" alt=""><figcaption><p>The Rotator Game Object is used as the Rotation Pivot for going up and down</p></figcaption></figure>

<figure><img src="/files/hHgxFJofsNBGSR8I3Nml" alt=""><figcaption><p>All Free movement states needs the Rotator Bone set.</p></figcaption></figure>

This Rotator Gameobject will be the parent of the RootBone of the Character (First bone of the hierarchy)

{% hint style="info" %}
Its local Position and Rotation value should be (0,0,0)
{% endhint %}

{% hint style="danger" %}

### Without setting this 'Rotator' gameObject on the Advanced tab the Fly State won't work properly

{% endhint %}

### Up Down Input

To move Up and Down on the Y-Axis the Animator Requires also the Optional parameter: **UpDown.**

This input is created automatically when the asset is installed.

<figure><img src="/files/mcgKN36wqX4CBClmrYQ1" alt=""><figcaption></figcaption></figure>

You can create it manually by clicking on the \[Create] Button of the Malbers Input Component.

This will allow the Animal to go **Up** by pressing \[Space], or **Down** by pressing \[C].

<figure><img src="/files/RAjT8ACsI8ndykEWGUI4" alt=""><figcaption></figcaption></figure>

## Activation

This state mainly uses an Input value to be Activated.

### By Input

When Pressing the Input Value for Fly

<figure><img src="/files/essrFdAVF0QoBT9VjsoE" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
To create a quick Input for Flying use the Malbers Input context menu:
{% endhint %}

<figure><img src="/files/96XskpYlxRVdEzhyZSMV" alt=""><figcaption></figcaption></figure>

This will be connected automatically with the state if the state has the same value for its Input.

<figure><img src="/files/eUsgJgWCimD2yyoCzrPZ" alt=""><figcaption></figcaption></figure>

### Using a Zone

A Zone can activate the flying state.

<figure><img src="/files/WFwTtAV2gpO4E7pXeC7w" alt=""><figcaption></figcaption></figure>

### Using a Reaction

Animal Reactions can be used to activate the state. Check [**Reactions**](/animal-controller/main-components/reactions.md)

## 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 is flying near the ground so he can land (when [**Can Land** ](/animal-controller/main-components/manimal-controller/states/fly.md#can-land)is enabled)
* The Input for fly is released (when the [**Fly Input**](/animal-controller/main-components/manimal-controller/states/fly.md#fly-input) is set to **pressed**)
* The Input for fly is toggled to off (when the [**Fly Input**](/animal-controller/main-components/manimal-controller/states/fly.md#fly-input) is set to **toggle**)

## Common State Tag Properties

These are the General tag option for the Fly state:

<figure><img src="/files/kyCiepqN3Zf0kkRtzDmK" alt=""><figcaption></figcaption></figure>

* **Main Tag \[Fly]**

<table data-header-hidden><thead><tr><th width="260.3333333333333"></th><th></th><th></th></tr></thead><tbody><tr><td>◻️RootMotion </td><td>☑️Sprint  </td><td>◻️Gravity  </td></tr><tr><td>◻️Grounded </td><td>◻️Custom Rotation </td><td>◻️Orient To Ground  </td></tr><tr><td>☑️Ignore Lower States </td><td>◻️Persistent = False</td><td>◻️Lock Move  </td></tr><tr><td>◻️Lock Input  </td><td>☑️+ Root Speed = True</td><td>☑️ + Pos Speed   </td></tr><tr><td>☑️ Free Movement  </td><td></td><td></td></tr></tbody></table>

### Limits

<figure><img src="/files/dkkB2Vy0eX0Dpu7Nb2pX" alt=""><figcaption></figcaption></figure>

You can set all the limits you need for your state.

The limits will block the state from Activating.

## Animator

The Fly state requires Animation States that are in charge of the Fly movement.&#x20;

<figure><img src="/files/Mo7dzWIW0NtuKjNvoyqU" alt=""><figcaption></figcaption></figure>

![](/files/-M3NDNZsj-T0GfxZ18wB)

All states have a core animation state. For fly is a blend tree with the Tag **Fly.**

![](/files/-M3NRfL2KT0gj4815TXG)

![](/files/-M3NEUgS3AqCAZiSXYXG)

Since the State is a moving state, the Speed Multiplier must be set as **Parameter** "**SpeedMultiplier**"

This Blend Tree is usually set this way:&#x20;

![](/files/-M3NLAMFaH3vkUfiPE9u)

![](/files/-M3NL5rGuOg5A_iiFPqP)

{% hint style="warning" %}
If you don't have all the animations, you can fill the missing states with duplicate animations
{% endhint %}

## Tag Modifiers

The Fly State has a “TakeOff”  and "Land" tag Modifier by default. This allows the fly state to have an entering and exiting animations before and after entering the core animation, which allows to modify core parameters on the Animal Controller while it is playing any of those animations.

{% hint style="info" %}
If your character does not have the **Take Off**  or **Land** Animations this can be ignored.
{% endhint %}

![](/files/-M3NRbcOKwl0d7X7r_Vg)

The values for the Animal parameters that the TakeOff and Land modify are:

<figure><img src="/files/tIQLj6fUcpfFP4azQ6nr" alt=""><figcaption></figcaption></figure>

## Speed Set

The Fly needs a new [**Speed Set**](/animal-controller/main-components/manimal-controller/speeds.md) that affects the Fly State. When creating for the first time the Speed Set will be added automatically to the Animal Controller:

<figure><img src="/files/IkkUI4aqbpGyeiTTmsvB" alt=""><figcaption></figcaption></figure>

{% hint style="success" %}
If your Fly animations are **NOT** RootMotion or they don't have the movement and turning speed you desire, then you need to **increase** the [Position ](/animal-controller/main-components/manimal-controller/speeds.md#position)and [Rotation ](/animal-controller/main-components/manimal-controller/speeds.md#rotation)values to be **greater** than zero
{% endhint %}

## Fly Parameters

<figure><img src="/files/jw4Zfca5aRoNLnhXFx0V" alt=""><figcaption></figcaption></figure>

### Bank

Banking angle amount used while turning

<img src="/files/-M3MoxNI0YUfvWMBUr_3" alt="Bank = 30" width="375">

<img src="/files/-M3MpGjH3ZHQ50rhSV99" alt="Bank = 0" width="375">

### **Pitch Limit:**

Limit Angle to Pitch the animal while going up and Down

<img src="/files/-M4-dGmntXs4BJejfJar" alt="" data-size="original"> <img src="/files/-M4-dmxx8vOhQgPL1O1h" alt="" data-size="original">&#x20;

&#x20;                        Pitch Limit = 30                          Pitch Limit = 80 (Default)

### **Bank Strafe**

Amount of banking the character can do while strafing and Flying.&#x20;

<figure><img src="/files/qJ07m28pIzsoLr3VSL48" alt=""><figcaption></figcaption></figure>

### **Pitch Strafe**

Amount of Pitch Rotation the character can do while strafing and Flying.&#x20;

<figure><img src="/files/U2mB3G6Wgwbv4TZA3sKX" alt=""><figcaption></figcaption></figure>

### **Max Height**

Max Height the character can fly

### Inertia Lerp

When Entering the Fly State... The animal will keep the Velocity from the last State if this value is greater than zero

(img)

<figure><img src="/files/XHM6U2fLYPt8tuMD23S1" alt=""><figcaption></figcaption></figure>

The take-off parameters will apply a force upwards to the character. This is usually used when the character does not have take-off animations.

### Take off Impulse

How much upward force will be applied

### Impulse Time

For how long the take-off impulse will be applied

### Impulse Curve

Curve value to apply to the TakeOff Impulse

<figure><img src="/files/8Qo2JLUh2ePUOqzXAn8H" alt=""><figcaption></figcaption></figure>

### Can Land

If the Animal is close to an object with the **Land On** Layer, it will automatically Land. (it will exit the Fly State)

### **Land On Layer**

Layer to search for Landing surfaces.&#x20;

### Land Multiplier

Ray Length multiplier to check for ground and automatically land (It uses the Chest Pivot as guide for the Land Ray)

### Inertia Lerp

When entering the Fly State... The animal will keep the velocity from the last State for a time if this value is greater than zero.

<figure><img src="/files/AdNrBKuDOdlctQAJ7kQd" alt=""><figcaption><p>Higher Lerp values will remove faster the acumulated inertia from the last state </p></figcaption></figure>

### Avoid Surface

<figure><img src="/files/dLKtQxW7r33zpTIWUXzA" alt=""><figcaption></figcaption></figure>

If enabled, It will avoid landing on any object using a surface layer mask. This is used usually for animals that cannot land on Water.

### Surface Layer&#x20;

Layer mask to search for surfaces that the animal cannot land.&#x20;

### Surface Distance&#x20;

The minimum length, the character will be placed above that surface, to keep it from touching that surface.

<figure><img src="/files/hp3E41SBNTpkNBzwZVQf" alt=""><figcaption><p>The raven will not enter the water and it will keep a distance </p></figcaption></figure>

### Gliding

<figure><img src="/files/dwE14s4B2xdxpxeh2Wz9" alt=""><figcaption></figcaption></figure>

### Flap Speed

Which Speed in the Animation Blend tree will be used to Flap the wings

### Glide Speed

Which  Speed in the Animation Blend tree will be used to Glide with the wings

<figure><img src="/files/cMjRDhFWsEYsnsnBGLkB" alt=""><figcaption><p>Vertical =1 is the Flap Speed. Vertical = 2 is the  Glide Speed in the Blend Tree</p></figcaption></figure>

### Glide Only

The character will activate only the glide animations and it cannot go upwards

### Glide Only Idle S

When the Forward Input is Released, this will be the movement speed the gliding will have

### Glide Only Idle V

When the Forward Input is Pressed, this will be the movement speed the gliding will have

### Auto Glide

If Enabled the animal will change from flapping to gliding automatically&#x20;

### Glide Chance

Time range the animal will glide when Auto Glide is true

### Flap Chance

Time range the animal will flap the wings when Auto Glide is true

### Variation

Variation to make Random Flap and Glide Animation

### Down Acceleration

Gravity Force applied to the Fly State.

<figure><img src="/files/UXxiULvcJVN8YoDSWC3H" alt=""><figcaption></figcaption></figure>

### Gravity Drag

If the value is greater than zero the character will go down gradually while flying.

### Down Acceleration

If the character plunges down toward the ground it will gain speed depending on the value of this parameter.

### Bone Block Landing

<figure><img src="/files/LPSETEfoXeIu7F1tt2xA" alt=""><figcaption></figcaption></figure>

Sometimes when the animal is very large and has a large head the landing may be blocked by the head and it cannot properly land. that is why, when **Can Land** is active, a second ray is cast from another bone (Head) to see if we can find ground to land.

### Bone Name

Name of the Bone. By default is "Head"

### Bone Offset Position

Local Offset position from the bone position

### Block Land Distance

Ray Distance for finding the ground from the Bone

###


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://malbersanimations.gitbook.io/animal-controller/main-components/manimal-controller/states/fly.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
