RealDocs

UCharacterMovementComponent::FloorSweepTest

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

Description

Sweeps a shape from Start to End against the world and returns the first blocking hit. Intended for floor tests, since it may change the impact result on the lower area of the sweep when bUseFlatBaseForFloorChecks is enabled.

Caveats & Gotchas

  • When bUseFlatBaseForFloorChecks is true, this performs up to two separate box sweeps (one rotated 45 degrees, one axis-aligned) instead of a single capsule sweep — noticeably more expensive than a plain SweepSingleByChannel call.
  • This is a thin wrapper around GetWorld()->SweepSingleByChannel(); it doesn't apply any of CharacterMovementComponent's own floor-validation logic (walkability, edge tolerance) — that's layered on top by FindFloor()/ComputeFloorDist().

Signature

virtual bool FloorSweepTest(struct FHitResult& OutHit, const FVector& Start, const FVector& End, ECollisionChannel TraceChannel, const struct FCollisionShape& CollisionShape, const struct FCollisionQueryParams& Params, const struct FCollisionResponseParams& ResponseParam) const

Parameters

Name Type Description Default
OutHit struct FHitResult& Receives the first blocking hit found.
Start const FVector& Start location of the sweep.
End const FVector& End location of the sweep.
TraceChannel ECollisionChannel Collision channel used to determine which components to hit.
CollisionShape const struct FCollisionShape& Capsule collision shape used for the sweep.
Params const struct FCollisionQueryParams& Additional query parameters for the trace.
ResponseParam const struct FCollisionResponseParams& Collision response container used for the trace.

Return Type

bool

Example

Manual downward sweep for a custom check C++
FHitResult Hit;
FCollisionQueryParams Params(SCENE_QUERY_STAT(MyFloorCheck), false, CharacterOwner);
FCollisionResponseParams ResponseParam;
InitCollisionParams(Params, ResponseParam);

const bool bHitFloor = FloorSweepTest(Hit, Start, End, UpdatedComponent->GetCollisionObjectType(), GetPawnCapsuleCollisionShape(SHRINK_None), Params, ResponseParam);

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.