Skip to content

MotionCrouchingComponent

MotionCrouchingComponent wraps Unreal's native crouch system with GAS integration, camera height coordination, speed effects, and uncrouch collision checks.

Requirements

  • Character with standard UCharacterMovementComponent and UCapsuleComponent
  • A resolvable UAbilitySystemComponent, commonly exposed by a PlayerState that implements IAbilitySystemInterface
  • Gameplay Ability System initialized
  • Enhanced Input configured
  • Crouch speed, wants-to-crouch, and crouching GameplayEffects
  • GameplayTags for crouch intent, active crouch, and walk speed

For setup and input binding steps, see How to add Motion to a character.

Behavior

The component uses Unreal's built-in Character->Crouch() and Character->UnCrouch() behavior. CharacterMovementComponent owns capsule resizing and built-in prediction. Motion adds input handling, GAS state, speed effects, event dispatch, blocked-uncrouch checks, and camera height notifications.

When the character crouches or stands, the component notifies the camera system through the event bus. The camera component then interpolates its own height independently from the capsule.

API

Crouch state

  • SetWantsToCrouch(bool bWantsToCrouch) -> void: sets crouch intent.
  • GetWantsToCrouch() -> bool: returns crouch intent.
  • IsCurrentlyCrouching() -> bool: returns Character->bIsCrouched.
  • IsFullyCrouched() -> bool: returns whether crouch is fully active.
  • IsUncrouchBlocked() -> bool: checks whether ceiling collision blocks standing.
  • GetCurrentCapsuleHalfHeight() -> float: returns current capsule half height.

State and collision

  • UpdateCrouchingState(float DeltaTime) -> void: updates crouch state and notifications.
  • InitializeCrouchComponent() -> void: initializes cached references.
  • HandleCrouchInputStateChange(bool bPressed) -> void: processes crouch input state.
  • GetCapsuleOverlapResult(const FVector& TestLocation, float TestHeight) -> bool: tests collision at a capsule height.

GAS and input

  • ApplyCrouchSpeedModification() -> void: applies crouch speed effect.
  • RemoveCrouchSpeedModification() -> void: removes crouch speed effect.
  • OnInputStarted(const FInputActionValue& Value) -> void: handles crouch input press.
  • OnInputCompleted(const FInputActionValue& Value) -> void: handles crouch input release.
  • BindCrouchInput(UInputAction* CrouchAction) -> bool: binds crouch input through auto-discovery.
  • BindCrouchInputWithComponent(UInputAction* CrouchAction, UEnhancedInputComponent* InputComponent) -> bool: binds crouch input through an explicit input component.

Utility and networking

  • GenerateCurveIdentifier() -> FName: inherited from UMotionComponentBase.
  • PrintDebugInformation() -> void: prints debug output when enabled.
  • ServerRequestCrouch(bool bWantsToCrouch) -> void: server RPC for authoritative crouch validation.

Configuration

Configuration lives on the assigned MotionCrouchProfile. The current Motion default is /MotionCore/Motion/Profiles/v2_0_0/DA_MotionCrouchProfile_Default_v2_0_0.

Crouch settings

  • CapsuleHalfHeightWhenCrouching: target capsule half height while crouched. Default: 48.0.
  • CrouchWalkSpeedModifier: walk speed value added while crouching. Default: -200.0.

GAS effects

  • CrouchSpeedEffect: effect for crouch speed modification.
  • WantsToCrouchTagEffect: grants wants-to-crouch tag.
  • CrouchingTagEffect: grants crouching state tag.

Speed modification uses SetByCaller_Magnitude_CrouchSpeed internally.

The component's editable setup surface is the Profile reference. Crouch input state, active effect handles, cached capsule values, and diagnostics remain component-owned.

Read-Only State

  • ActiveCrouchSpeedEffectHandle: handle to active speed effect.
  • WantsToCrouchTagHandle: handle to wants-to-crouch tag effect.
  • CrouchingTagHandle: handle to crouching state tag effect.
  • OriginalCapsuleHalfHeight: capsule half height cached at BeginPlay.
  • CachedCapsuleComponent: inherited cached capsule reference.
  • CachedEventBus: inherited cached camera event bus.
  • bWasCrouchedLastFrame: previous bIsCrouched state.
  • bWasBlockedLastFrame: tracks blocked uncrouch state so the event fires once.
  • bShowDebugInformation: debug display flag.

Blueprint Events

  • OnCrouchStateChanged(bool bIsCrouching): fires when crouch state changes.
  • OnCrouchBlocked(): fires when uncrouching is blocked.
  • OnCrouchTransitionCompleted(bool bIsNowCrouched): fires when crouch transition completes.

State Access

  • GetWantsToCrouch(): checks whether crouch input is held.
  • IsCurrentlyCrouching(): checks Character->bIsCrouched.
  • IsFullyCrouched(): same as current crouch for instant transitions.
  • IsUncrouchBlocked(): checks whether ceiling collision prevents standing.
  • GetCurrentCapsuleHalfHeight(): returns current capsule half height.

Networking

Crouch uses Unreal's native crouch RPCs through CharacterMovementComponent. GAS speed and tag effects replicate separately, while camera interpolation remains local to each client.

Motion - Advanced First Person Character Controller