UCharacterMovementComponent::IsWithinEdgeTolerance
#include "GameFramework/CharacterMovementComponent.h"
Access: public
Specifiers: virtualconst
Description
Returns true if the 2D distance from CapsuleLocation to TestImpactPoint is within the capsule radius minus a small rejection threshold, used to reject hits too close to the capsule's edge.
Caveats & Gotchas
- • Only considers horizontal (2D) distance — it deliberately ignores the Z component, since it's designed to test edge proximity on floor sweeps, not full 3D distance.
- • Used by FindFloor()/ComputeFloorDist() internally to discard sweep results that clipped the capsule's edge rather than landing solidly under it; overriding it changes how forgiving floor detection is near ledges.
- • A stricter (smaller effective tolerance) override can cause characters to report 'no floor' more often near ledges, increasing unwanted falling; a looser one can cause characters to stand on floor edges that visually look like they should fall.
Signature
virtual bool IsWithinEdgeTolerance(const FVector& CapsuleLocation, const FVector& TestImpactPoint, const float CapsuleRadius) const; Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| CapsuleLocation | const FVector& | Location of the capsule being tested. | — |
| TestImpactPoint | const FVector& | Impact point from a floor/hit sweep to test against the capsule's edge. | — |
| CapsuleRadius | const float | Radius of the capsule being tested. | — |
Return Type
bool Example
Checking edge tolerance manually against a sweep result C++
bool UMyCharacterMovementComponent::IsHitOnCapsuleEdge(const FHitResult& Hit) const
{
const FVector CapsuleLocation = UpdatedComponent->GetComponentLocation();
const float CapsuleRadius = CharacterOwner->GetCapsuleComponent()->GetScaledCapsuleRadius();
return !IsWithinEdgeTolerance(CapsuleLocation, Hit.ImpactPoint, CapsuleRadius);
} Tags
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?