RealDocs

UCharacterMovementComponent::ComputePerchResult

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

Description

Sweeps a smaller capsule of TestRadius to determine whether the character could stand perched at the edge represented by InHit, within InMaxFloorDist of the impact point.

Caveats & Gotchas

  • Only produces a meaningful result if ShouldComputePerchResult() already returned true for the same hit — calling it unconditionally can misclassify unwalkable edges as valid perches.
  • Returns false immediately if InMaxFloorDist <= 0, which happens whenever the caller determines there's no headroom left to perch within.

Signature

virtual bool ComputePerchResult(const float TestRadius, const FHitResult& InHit, const float InMaxFloorDist, FFindFloorResult& OutPerchFloorResult) const

Parameters

Name Type Description Default
TestRadius const float Radius to use for the sweep, usually GetValidPerchRadius().
InHit const FHitResult& Result of the last sweep test before this query.
InMaxFloorDist const float Max distance to the floor allowed by perching, measured from InHit.ImpactPoint.
OutPerchFloorResult FFindFloorResult& Out parameter that receives the result of the perch floor test.

Return Type

bool

Example

Validate a perch location found by ShouldComputePerchResult C++
FFindFloorResult PerchFloorResult;
if (ShouldComputePerchResult(DownwardSweepHit) && ComputePerchResult(GetValidPerchRadius(), DownwardSweepHit, MaxStepHeight, PerchFloorResult))
{
	// PerchFloorResult now describes a valid perch location.
}

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.