Skip to content

MotionCrouchingComponent

MotionCrouchingComponent wraps the native Unreal crouch system. It adds GAS integration, camera height coordination, speed effects, and uncrouch collision checks.

Requirements

  • The character must have a standard UCharacterMovementComponent and UCapsuleComponent.
  • Motion must find a UAbilitySystemComponent. A PlayerState that implements IAbilitySystemInterface can expose this component.
  • You must initialize the Gameplay Ability System.
  • You must configure Enhanced Input.
  • You must configure crouch speed, wants-to-crouch, and crouching GameplayEffects.
  • You must configure GameplayTags for crouch intent and active crouch.

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

Behavior

The component uses the native Unreal Character->Crouch() and Character->UnCrouch() behavior. CharacterMovementComponent owns capsule resize operations and native prediction. Motion adds input handling, GAS state, speed effects, blocked-uncrouch events, clearance checks, and camera height updates.

When the locally controlled character crouches or stands, the component updates its MotionCameraComponent height when one is present. The camera component then interpolates its own height independently from the capsule.

API

Commands

  • SetWantsToCrouch(bool bWantsToCrouch) -> void: sets crouch intent.

GAS and input

  • HandleCrouchInputStateChange(bool bPressed) -> void: processes crouch input push and release with local prediction and server RPC.

Profile

  • GetProfile() -> UMotionCrouchProfile*: returns the assigned crouch profile.
  • SetProfile(UMotionCrouchProfile* NewProfile) -> void: assigns a setup-time profile before BeginPlay.
  • HasValidProfile() -> bool: returns whether the assigned profile validates.

Configuration

Configuration is in the assigned MotionCrouchProfile. The default Motion profile for this release 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.
  • bRequiresContinuousInput: When true, the input must stay active. When false, each input action changes crouch intent. The default is true.

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 primary setting that you edit is the Profile reference. GameplayEffect class references stay on the profile. Crouch input state, active effect handles, cached capsule values, and diagnostics stay on the component.

Runtime State

Most of these fields are protected component state. Derived Blueprints have read-only access to some fields. Active effect handles remain C++ implementation details. bShowDebugInformation is public debug configuration.

  • 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.
  • CachedCameraComponent: inherited cached Motion camera reference.
  • bWasCrouchedLastFrame: previous bIsCrouched state.
  • bWasBlockedLastFrame: tracks blocked uncrouch state so the event fires once.
  • bShowDebugInformation: debug display flag.

Blueprint Events

  • OnCrouchBlockedDelegate(): fires when uncrouching is blocked.

State Access

  • Crouch intent: Read Motion.State.WantsToCrouch on the AbilitySystemComponent of the actor.
  • Active crouch: use native ACharacter::IsCrouched() or Motion.State.Crouching.
  • Capsule height: Read the UCapsuleComponent of the owning character.

Networking

The owning input path predicts a loose wants-to-crouch tag and sends ServerRequestCrouch. It also calls native ACharacter::Crouch() or UnCrouch(). CharacterMovementComponent handles this movement state. Server-owned GAS speed and state effects replicate separately. Camera interpolation operates only for the locally controlled view.

Motion - Advanced First Person Character Controller