RealDocs

UCharacterMovementComponent::ShouldCatchAir

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

Description

Hook called while walking when the character moves from one walkable floor to another, letting subclasses decide whether the transition should instead trigger falling.

Caveats & Gotchas

  • The base implementation always returns false — walking never automatically starts falling just because the floor changed, even across a step or slope change, as long as both floors are walkable.
  • This is the standard override point for 'catch air' gameplay (e.g. leaving the ground when running off a ramp at speed) — compare OldFloor and NewFloor's slope/normal to decide when to return true.

Signature

virtual bool ShouldCatchAir(const FFindFloorResult& OldFloor, const FFindFloorResult& NewFloor)

Parameters

Name Type Description Default
OldFloor const FFindFloorResult& Floor result from before the character moved.
NewFloor const FFindFloorResult& Floor result at the character's new position.

Return Type

bool

Example

Catching air off steep slope changes C++
bool UMyCharacterMovementComponent::ShouldCatchAir(const FFindFloorResult& OldFloor, const FFindFloorResult& NewFloor)
{
    const float SlopeDot = FVector::DotProduct(OldFloor.HitResult.ImpactNormal, NewFloor.HitResult.ImpactNormal);
    return Velocity.SizeSquared2D() > FMath::Square(600.f) && SlopeDot < 0.9f;
}

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.