UCharacterMovementComponent::ComputeFloorDist
#include "GameFramework/CharacterMovementComponent.h"
Access: public
Specifiers: virtual
Description
Computes the swept distance from the bottom of the capsule to the first walkable point of impact and stores the result in OutFloorResult, ignoring whether the capsule's own collision is enabled.
Caveats & Gotchas
- • SweepDistance must be greater than or equal to LineDistance — the header calls this out explicitly, and the function does not clamp or validate it for you (unlike its K2_ComputeFloorDist Blueprint wrapper).
- • If DownwardSweepResult already contains a valid blocking hit, the function reuses it instead of performing its own sweep, which can produce misleading results if that hit came from a different location than CapsuleLocation.
Signature
virtual void ComputeFloorDist(const FVector& CapsuleLocation, float LineDistance, float SweepDistance, FFindFloorResult& OutFloorResult, float SweepRadius, const FHitResult* DownwardSweepResult = NULL) const Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| CapsuleLocation | const FVector& | Location of the capsule used for the query. | — |
| LineDistance | float | Max distance to test with a simple line trace from the capsule base. | — |
| SweepDistance | float | Max distance to sweep the capsule downward; must be greater than or equal to LineDistance. | — |
| OutFloorResult | FFindFloorResult& | Out parameter that receives the result of the floor check. | — |
| SweepRadius | float | Radius to use for the sweep test; should be no greater than the capsule radius. | — |
| DownwardSweepResult | const FHitResult* | If non-null with a valid blocking hit, used as the result of the downward sweep instead of performing one. | NULL |
Return Type
void Example
Measure distance to the floor C++
UCharacterMovementComponent* Move = GetCharacterMovement();
float Radius, HalfHeight;
GetCapsuleComponent()->GetScaledCapsuleSize(Radius, HalfHeight);
FFindFloorResult FloorResult;
Move->ComputeFloorDist(GetActorLocation(), Move->MaxStepHeight, Move->MaxStepHeight, FloorResult, Radius); See Also
Tags
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?