> 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/underwater.md).

# UnderWater

Incomplete (1.4.2d)

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:

![](https://963537199-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Lzhr1XSMzMqNXjRnNlb%2F-M5THfy-Pi-YkZb0TOg3%2F-M5UmYyQPmqPsMGbZRL0%2Fimage.png?alt=media\&token=d7fdfa83-acaf-418a-9fd8-a919d1bc7c4b)

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.

![](https://963537199-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Lzhr1XSMzMqNXjRnNlb%2F-MP9ytgqNs2P244ewkab%2F-MPA5EVd0jgT0pwCI3ym%2Fimage.png?alt=media\&token=c5cb5825-b6da-44dd-82a0-718ce44da5f1)

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="https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2FZLtqce40PCReuHdrkH8x%2Fimage.png?alt=media&amp;token=8d20c898-2c5d-4290-ba4b-a119d8356914" 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.

![](https://963537199-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Lzhr1XSMzMqNXjRnNlb%2F-MP9ytgqNs2P244ewkab%2F-MPA6IYBEFoKUp3lpWSE%2Fimage.png?alt=media\&token=f984b81b-4714-4ac4-9619-8ce06fcf0c3c)

* **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](https://963537199-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Lzhr1XSMzMqNXjRnNlb%2F-MP9ytgqNs2P244ewkab%2F-MPA7FWxRJtO6ZFGPU-q%2Fimage.png?alt=media\&token=6e203177-3e95-4b00-867f-c77102583c72)

![](https://963537199-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Lzhr1XSMzMqNXjRnNlb%2F-MP9ytgqNs2P244ewkab%2F-MPA7O9dVUAkrSGLsE0X%2Fimage.png?alt=media\&token=e9971a71-53d2-41a0-9632-fefe4de6f661)

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

![](https://963537199-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Lzhr1XSMzMqNXjRnNlb%2F-MP9ytgqNs2P244ewkab%2F-MPA7eBtiklhpYQCHWg_%2Fimage.png?alt=media\&token=ce2452d7-b309-4494-aa2c-a92cf67dcb23)

![](https://963537199-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Lzhr1XSMzMqNXjRnNlb%2F-MP9ytgqNs2P244ewkab%2F-MPA7oasL3M2I2UhA5uL%2Fimage.png?alt=media\&token=824750c9-ab4c-4192-a51c-ed84b769a376)

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;

![](https://963537199-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Lzhr1XSMzMqNXjRnNlb%2F-MPA7vraqCO9uYuCTM0h%2F-MPA896UgJgyReiKjJ52%2Fimage.png?alt=media\&token=617c7959-a41a-4277-988a-265e804d06bb)

![](https://963537199-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Lzhr1XSMzMqNXjRnNlb%2F-MPA7vraqCO9uYuCTM0h%2F-MPA8HylH2lTQjRjXrjS%2Fimage.png?alt=media\&token=8495428c-9618-476c-9eaa-9477255d5ab6)

{% 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

![](https://963537199-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Lzhr1XSMzMqNXjRnNlb%2F-MPA7vraqCO9uYuCTM0h%2F-MPA8dAiARwaTc08SDYK%2Fimage.png?alt=media\&token=2b84379e-5602-4bdd-ad16-8463c74b8514)

{% 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

![](https://963537199-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Lzhr1XSMzMqNXjRnNlb%2F-MPA8vKb1k63LdvM44tI%2F-MPA99j30S-pKcZDYysq%2Fimage.png?alt=media\&token=343b5ef9-a7f0-453c-b02d-eabc042cb161)

### Bank

Banking angle amount used while turning

![Bank = 30](https://963537199-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Lzhr1XSMzMqNXjRnNlb%2F-M3MnarBY6UtfvetYOAG%2F-M3MoxNI0YUfvWMBUr_3%2FUgVX156gCD.gif?alt=media\&token=779a0296-0de6-4c84-bf76-f8767ee82ae2)

![Bank = 0](https://963537199-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Lzhr1XSMzMqNXjRnNlb%2F-M3MnarBY6UtfvetYOAG%2F-M3MpGjH3ZHQ50rhSV99%2F8WU0AAIMfa.gif?alt=media\&token=53a1740f-915b-4a77-8ef7-780bb0ce5a22)

### **YLimit:**

Limit Angle to Pitch the animal while going up and Down

<img src="https://963537199-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Lzhr1XSMzMqNXjRnNlb%2F-M4-Tb1tDwrluXN0N41a%2F-M4-dGmntXs4BJejfJar%2FsssfJO7H6g.gif?alt=media&amp;token=2fc20a25-cfee-4391-9d21-bcc045004612" alt="" data-size="original"> <img src="https://963537199-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Lzhr1XSMzMqNXjRnNlb%2F-M4-Tb1tDwrluXN0N41a%2F-M4-dmxx8vOhQgPL1O1h%2FXQ6FM35HcT.gif?alt=media&amp;token=57c16cfb-a5fc-48e3-854c-867f682afb9f" 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.
