ACharacter::OnWalkingOffLedge_Implementation
#include "GameFramework/Character.h"
Access: public
Specifiers: virtual
Description
C++ override point for the BlueprintNativeEvent fired when the character is about to walk off a ledge because the floor became unwalkable. Override this in C++ subclasses to apply custom velocity or prevent the fall by changing MovementMode.
Caveats & Gotchas
- • Z velocity is zero during walking movement and will also be zero here. Any upward launch velocity must be set explicitly in this override before the character transitions to falling.
- • If `CharacterMovementComponent->MovementMode` is not changed during this callback, the character will automatically begin falling. This is the correct place to redirect the character if you want to prevent the fall.
- • Blueprint subclasses should use the `OnWalkingOffLedge` event (the BlueprintNativeEvent entry point), not this `_Implementation` method directly.
Signature
ENGINE_API virtual void OnWalkingOffLedge_Implementation(const FVector& PreviousFloorImpactNormal, const FVector& PreviousFloorContactNormal, const FVector& PreviousLocation, float TimeDelta) Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| PreviousFloorImpactNormal | const FVector& | Normal of the previously walkable floor surface that was impacted. | — |
| PreviousFloorContactNormal | const FVector& | Normal of the contact with the previous walkable floor. | — |
| PreviousLocation | const FVector& | Character world location just before moving off the ledge. | — |
| TimeDelta | float | Time delta of the movement update that caused the ledge departure. | — |
Return Type
void Example
Apply launch velocity when walking off a ledge C++
void AMyCharacter::OnWalkingOffLedge_Implementation(
const FVector& PreviousFloorImpactNormal,
const FVector& PreviousFloorContactNormal,
const FVector& PreviousLocation,
float TimeDelta)
{
Super::OnWalkingOffLedge_Implementation(
PreviousFloorImpactNormal, PreviousFloorContactNormal,
PreviousLocation, TimeDelta);
// Give a small horizontal boost in the ledge direction
FVector LaunchDir = PreviousFloorContactNormal;
LaunchDir.Z = 0.f;
LaunchVelocity(LaunchDir.GetSafeNormal() * 200.f, false, false);
} Tags
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?