# UnderWater

The Underwater state is in charge of allowing the character to swim underwater. Its State [**ID** ](/animal-controller/scriptable-architecture/scriptables/scriptable-ids.md#states-ids)is **5.**

{% embed url="<https://streamable.com/30pp6m>" %}

## Creating the Swim Underwater State

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

![](/files/-M5UmYyQPmqPsMGbZRL0)

Or just duplicate any of the already created Underwater Swim 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)**,** [**Fall**](/animal-controller/main-components/manimal-controller/states/fall.md)**,** [**Swim** ](/animal-controller/main-components/manimal-controller/states/swim.md)and [**Fly**](/animal-controller/main-components/manimal-controller/states/fly.md). but below [**Death**](/animal-controller/main-components/manimal-controller/states/death.md) since the animal can be killed any time.

![](/files/-MPA5EVd0jgT0pwCI3ym)

When the animal is on the this state, all the Lower priorities states are ignored until the exit conditions for this state are fulfilled.&#x20;

The **\<Swim Underwater>** **Exit conditions** are:

* The animal is moving upwards (Y Axis) and is near the Upper Limit of the water trigger collider.

## Requirements

### Swim State&#x20;

In order to work properly, the animal also needs the **Swim** State to be set, since the Underwater state will use some functions from the Swim State, to find the Water trigger.

### Rotator&#x20;

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

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

{% hint style="danger" %}

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

{% endhint %}

* To move Up and Down on the Y Axis the Animator Requires the parameter: **UpDown,** which controls the underwater swim for going upwards or downwards&#x20;

*

## Activation

## Exit Conditions

## Common State Properties

The basic setting for the Swim Underwater state, is very similar for all the animals.

![](/files/-MPA6IYBEFoKUp3lpWSE)

* **ID =** SwimUnderwater ID
* **Input:**  \<None>, This state is activated automatically when the Down Input is pressed.&#x20;
* **General**
  * **RootMotion** = false
  * **Sprint** = true
  * **Gravity** = false
  * **Grounded** = false
  * **Custom Rotation** = false
  * **Orient to Ground** = false
  * **Ignore Lower States** = true
  * **Persistent**  = false
  * **Lock Movement** = false
  * **Lock Input** = false
  * **Additional Position Speed** = true
  * **Additional Rotation Speed** = true
  * **Free Move** = true
* **Exit Frame** = true
* **Exit on Main** = true
* Sleep From State: 0
* Sleep from Mode = 0
* Queue From = 0

## Animator

The Swim Underwater state requires Animation States that are in charge of all swimming underwater movement.&#x20;

![The Transition Enter Condition of this state is State=5](/files/-MPA7FWxRJtO6ZFGPU-q)

![](/files/-MPA7O9dVUAkrSGLsE0X)

All states have a core animation state. For Swim Underwater is a **blend tree** with the Tag **UnderWater.**

![](/files/-MPA7eBtiklhpYQCHWg_)

![](/files/-MPA7oasL3M2I2UhA5uL)

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/-MPA896UgJgyReiKjJ52)

![](/files/-MPA8HylH2lTQjRjXrjS)

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

## Speed Set <a href="#speed-set" id="speed-set"></a>

Swim Undewater need a new [**Speed Set**](https://malbersanimations.gitbook.io/animal-controller/main-components/manimal-controller/speeds) that affect the Underwater State

![](/files/-MPA8dAiARwaTc08SDYK)

{% hint style="success" %}
If your Underwater 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 %}

## Underwater Parameters&#x20;

This parameters are the same from the Fly State

![](/files/-MPA99j30S-pKcZDYysq)

### Bank

Banking angle amount used while turning

![Bank = 30](/files/-M3MoxNI0YUfvWMBUr_3)

![Bank = 0](/files/-M3MpGjH3ZHQ50rhSV99)

### **YLimit:**

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;                        Ylimit = 30                                                 Ylimit = 80 (Default)

### Enter Water Drag

It will push the animal down into the water for a given time

### Try Exit Time

This avoid instant exiting the state, it will wait a bit before allowing exiting the state.


---

# 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/underwater.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.
