ACharacter::CanCrouch
#include "GameFramework/Character.h"
Access: public
Specifiers: virtualENGINE_APIUFUNCTIONBlueprintCallable
Description
Returns true if the character is currently able to crouch and is not already crouching. Delegates to CharacterMovementComponent::CanCrouchInCurrentState().
Caveats & Gotchas
- • This checks the movement component's state (e.g. bCanCrouch must be true on the CharacterMovementComponent), so calling Crouch() without verifying CanCrouch() first can result in a silent no-op.
- • Crouching while Falling is allowed by default if the movement component permits it. If you want to restrict crouching to grounded states only, override this function and add an IsFalling() guard.
Signature
ENGINE_API virtual bool CanCrouch() const; Return Type
bool Examples
Check CanCrouch before calling Crouch on the player character
Blueprint
Conditionally trigger crouch on input C++
void AMyCharacter::StartCrouching()
{
if (CanCrouch())
{
Crouch();
}
} Tags
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?