CrouchState allows the actor to crouch.

Public Methods

public bool WillAllowMovement()

Uses the crouch settings to determine if the actor can move left and right while crouching.

public bool CanExitCrouch()

Determines if the actor is able to exit its crouching state. Will return false if the actor is in a confined space and doesn’t have enough room to stand up.

Public Members

public const string idString = “Crouching”;

public Vector2 colliderSize

The size of the actor’s collider while crouched. Typically set to be the same width as the actor’s standing state, but not as tall.

public Vector2 colliderOffset

The offset of the collider while the actor is crouched. Typically set to have 0 X offset and a negative Y offset which keeps the collider on the ground.

public float moveSpeed

The horizontal movement speed the actor will have while crouch-moving.

public bool willRiseWithButtonRelease

If True, the actor will exit its crouching state as soon as the “down” button is released. If False, the player must manually exit the state by pressing “up” or otherwise canceling the state via another action.

public bool canMove

If False, the actor cannot move horizontally while crouched.

public bool canJump

If False, the actor cannot jump out of a crouch.

public bool mustReleaseButtonToMove

If True, the actor cannot move horizontally until the “left” and “right” buttons are released after entering a crouch.

public bool immediatelyKillDecelerationOnCrouch

If the actor’s MovingState allows deceleration, setting this to True will kill that deceleration as soon as a crouch is entered.

public AnimationClip movingAnimation

The AnimationClip that plays while the actor crouch-moves.

public bool allowAccelerationOnMove

If the actor’s MovingState allows acceleration, setting this to False will disable that acceleration while crouch-moving.

public bool isSkidComplete

Used internally to determine if the actor has finished its initial horizontal deceleration after crouching.

public bool hasPlayerReleasedHorizontal

Whether or not the player has released the “left” and “right” buttons since crouching. Used internally.