Cover

The Cover ability allows the character to take standing and crouching cover. When the character aims they will pop out of cover and aim in the direction of the crosshairs. The Cover ability is a subclass of the Detect Object Ability Base ability allowing it to use that class in order to detect when the character can take cover.

Setup

  1. Select the + button in the ability list under the “Abilities” foldout of the Ultimate Character Locomotion component.
  2. Add the Cover ability. The Cover ability should be positioned toward the top of the ability list.
  3. Use the Object Detection field to specify how the character should detect a cover point. If the character is an AI agent the PredeterminedMoveTowardsLocation property can be set.
  4. Add the Move Towards Location to the cover object indicating where the character should take cover from.
  5. Adjust the Exposed Distance to determine which side the character can aim from. The x value indicates the local horizontal offset from the center of the character that the character can aim from. The z value indicates the length of the raycast to detect if an obstructing object was hit. The Debug Exposed Distance Ray field can be enabled to visualize the raycast.

Animator States

The states from the Deathmatch AI Kit demo animator can easily be added to your own character by clicking on the “Build Animator” button under the Editor foldout of the Cover ability. This will add the states to the animator that your character is using.

Inspected Fields

Debug Exposed Distance Ray

Should a debug ray be drawn for the exposed distance?

Move Speed

The speed at which the character moves towards the cover location.

Depth Offset

The offset between the cover object and the character.

Exposed Distance

The distance when determining which side to aim from.

Can Take Crouching Cover

Can the character take crouching cover?

Crouch Height Parameter

The value to set the Height Animator parameter value to when crouching.

Min Auto Cover Switch Duration

The minimum duration that the character can automatically switch between crouching cover and standing cover based on the cover object.

Exposed State Name

The name of the state when the character is aiming while exposed from the cover position.