UCharacterMovementComponent::IsValidLandingSpot
#include "GameFramework/CharacterMovementComponent.h"
Access: public
Specifiers: virtual
Description
Determines whether a hit result is a valid surface for the character to land on when falling, rejecting unwalkable normals, hits above the capsule's lower hemisphere, and hits too close to the capsule's edge.
Caveats & Gotchas
- • Performs a full FindFloor() call internally to confirm walkability, so it isn't a cheap check — avoid calling it every frame outside of the falling-movement pipeline.
- • When the hit is a penetrating hit (Hit.bStartPenetrating), most of the rejection checks are skipped and only the hit normal's vertical component is tested, relying on the subsequent FindFloor() call (with a smaller capsule) to resolve the penetration.
Signature
virtual bool IsValidLandingSpot(const FVector& CapsuleLocation, const FHitResult& Hit) const Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| CapsuleLocation | const FVector& | Location of the capsule at the time of the hit. | — |
| Hit | const FHitResult& | Hit result to validate as a landing spot. | — |
Return Type
bool Example
Validate a landing spot before committing to a fall recovery C++
const FVector CapsuleLocation = UpdatedComponent->GetComponentLocation();
if (IsValidLandingSpot(CapsuleLocation, Hit))
{
SetMovementMode(MOVE_Walking);
}
else
{
SetMovementMode(MOVE_Falling);
} See Also
Tags
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?