Align To Ground
The Align To Ground ability will orient the character to the direction of the ground’s normal. A cast will be performed downward to detect the rotation that the character should orient towards. The Distance determines the length of the cast. Depth Offset allows for multiple raycasts to be used which allows the result to be averaged. This is most useful for long generic characters (such as a horse) but it can also be used by humanoids to smooth the result.
If the Depth Offset is zero a cast in the shape of all of the colliders added to the character will be performed in the downward direction:
In this screenshot the cast is represented by the yellow line. Note that the cast is represented by a line here but a capsule cast is actually being performed because a Capsule Collider has been added to the character. The length of the cast is determined by Distance.
If the Depth Offset is not zero then two raycasts will be performed:
Similar to the last screenshot the casts are represented by the yellow line. In this situation a raycast will always be performed with the specified offset value. The character orientation will be determined by averaging the two raycast normal results.
Setup
- Select the + button in the ability list under the “Abilities” foldout of the Ultimate Character Locomotion component.
- Add the Align To Ground ability. The ability is concurrent so the ability can be positioned anywhere within the ability list.
Inspected Fields
Distance
The distance from the ground that the character should align itself to.
Depth Offset
The depth offset when checking the ground normal.
Normalize Direction
Should the direction from the align to ground depth offset be normalized? This is useful for generic characters whose length is long.
Rotation Speed
Specifies the speed that the character can rotate to align to the ground.
Stop Gravity Direction
The direction of gravit that should be set when the ability stops. Set to Vector3.zero to disable.