ACharacter::IsCrouched
#include "GameFramework/Character.h"
Access: public
Specifiers: const
Description
Returns true if the Character is currently crouched. Reads the replicated `bIsCrouched` flag which is set by CharacterMovementComponent when a crouch is applied.
Caveats & Gotchas
- • bIsCrouched is replicated — on clients it reflects the server's committed crouch state after the replication update. There can be a one-frame lag between requesting a crouch (Crouch()) and IsCrouched() returning true.
- • Crouching is not instantaneous; CharacterMovementComponent processes the Crouch request on its next update. Checking IsCrouched() in the same frame as Crouch() will still return false.
Signature
ENGINE_API bool IsCrouched() const; Return Type
bool Example
Adjust movement speed based on crouch state C++
void AMyCharacter::UpdateSpeed()
{
float TargetSpeed = IsCrouched() ? CrouchSpeed : WalkSpeed;
GetCharacterMovement()->MaxWalkSpeed = TargetSpeed;
} See Also
Tags
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?