RealDocs

UCharacterMovementComponent::Crouch

function Engine Since 4.0
#include "GameFramework/CharacterMovementComponent.h"
Access: public Specifiers: virtual

Description

Checks that the reduced capsule size fits without encroachment and, if so, shrinks the capsule and calls CharacterOwner->OnStartCrouch(). Does nothing if CanCrouchInCurrentState() would disallow crouching.

Caveats & Gotchas

  • This is the low-level implementation — for gameplay code, call ACharacter::Crouch() instead, which sets bIsCrouched/bWantsToCrouch and replicates correctly. Calling this directly on the server does not set those flags.
  • If the capsule would encroach on geometry at the crouched height, the function silently does nothing; it never partially crouches or reports failure back to the caller.
  • On non-owning simulated proxies, this only runs in response to replicated state via bClientSimulation=true — calling it manually there fights the replication system.

Signature

virtual void Crouch(bool bClientSimulation = false)

Parameters

Name Type Description Default
bClientSimulation bool True when this call is reacting to bIsCrouched being replicated to a non-owning client, rather than an authoritative crouch request. false

Return Type

void

Example

Preferred entry point via ACharacter C++
// Prefer this over calling UCharacterMovementComponent::Crouch directly:
ACharacter* MyCharacter = GetCharacterOwner();
if (MyCharacter && MyCharacter->CanCrouch())
{
	MyCharacter->Crouch();
}

Version History

Introduced in: 4.0

Version Status Notes
5.6 stable

Feedback

Was this helpful?

Suggest an edit

Select a field above to begin editing.