RealDocs

ACharacter::CanCrouch

function Engine Blueprint Since 4.0
#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
Event BeginPlay Cast To MyCharacter Object Cast Failed As My Character As My Character Branch Condition Condition True False Crouch Target is Character Target Get Player Character Player Index 0 0 Return Value Can Crouch Target is Character Target Return Value
Edit Blueprint graph Check CanCrouch before calling Crouch on the player character
Drag node headers to move · Drag from an output pin to an input pin to connect · Scroll to zoom · Right-click for actions
Conditionally trigger crouch on input C++
void AMyCharacter::StartCrouching()
{
    if (CanCrouch())
    {
        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.