🐊UnderWater
Incomplete (1.4.2d)
The Underwater state is in charge of allowing the character to swim underwater. Its State ID is 5.
Creating the Swim Underwater State
To create a new State Click the Plus button on the States list:
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, Locomotion, Fall, Swim and Fly. but below Death since the animal can be killed any time.
When the animal is on the this state, all the Lower priorities states are ignored until the exit conditions for this state are fulfilled.
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
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
The State requires an Empty Transform set as a Rotator. This Rotator is in charge of Pitch and bank rotation of the animal while swimming underwater.
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
Activation
Exit Conditions
Common State Properties
The basic setting for the Swim Underwater state, is very similar for all the animals.
ID = SwimUnderwater ID
Input: <None>, This state is activated automatically when the Down Input is pressed.
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.
All states have a core animation state. For Swim Underwater is a blend tree with the Tag UnderWater.
Since the State is a moving state, the Speed Multiplier must be set as Parameter "SpeedMultiplier"
This Blend Tree is usually set this way:
If you don't have all animations, you can fill the missing states with the duplicate animations
Speed Set
Swim Undewater need a new Speed Set that affect the Underwater State
Underwater Parameters
This parameters are the same from the Fly State
Bank
Banking angle amount used while turning
YLimit:
Limit Angle to Pitch the animal while going up and Down
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.
Last updated