UWorld::SweepMultiByChannel
#include "Engine/World.h"
Access: public
Specifiers: const
Description
Sweeps a collision shape from Start to End and returns all overlapping hits along the path, plus the first blocking hit. Unlike SweepSingleByChannel, this collects every overlap — useful for multi-hit detection such as piercing projectiles or area sweeps.
Caveats & Gotchas
- • Results are sorted: initial overlaps come first, with the first blocking hit appended at the end. Only one blocking hit is ever returned — the sweep stops generating results after the first blocking contact.
- • Returns true only if OutHits contains a blocking hit. Overlaps alone return false — check each FHitResult.bBlockingHit individually if you need to detect pure overlaps.
- • OutHits is not cleared before the sweep — always empty or reset the array before calling to avoid accumulating stale results.
Signature
bool SweepMultiByChannel(TArray<struct FHitResult>& OutHits, const FVector& Start, const FVector& End, const FQuat& Rot, ECollisionChannel TraceChannel, const FCollisionShape& CollisionShape, const FCollisionQueryParams& Params = FCollisionQueryParams::DefaultQueryParam, const FCollisionResponseParams& ResponseParam = FCollisionResponseParams::DefaultResponseParam) const Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| OutHits | TArray<struct FHitResult>& | Array populated with all hits found during the sweep. | — |
| Start | const FVector& | World-space start location of the shape. | — |
| End | const FVector& | World-space end location of the shape. | — |
| Rot | const FQuat& | Rotation of the shape, held constant throughout the sweep. | — |
| TraceChannel | ECollisionChannel | The collision channel used to determine which components to hit. | — |
| CollisionShape | const FCollisionShape& | The shape to sweep — supports Box, Sphere, or Capsule. | — |
| Params | const FCollisionQueryParams& | Additional query parameters such as actors to ignore. | FCollisionQueryParams::DefaultQueryParam |
| ResponseParam | const FCollisionResponseParams& | Response container controlling blocking vs overlap behaviour per channel. | FCollisionResponseParams::DefaultResponseParam |
Return Type
bool Example
Capsule sweep collecting all hits along a path C++
TArray<FHitResult> Hits;
FCollisionShape Capsule = FCollisionShape::MakeCapsule(34.f, 88.f);
FCollisionQueryParams Params;
Params.AddIgnoredActor(this);
bool bBlocked = GetWorld()->SweepMultiByChannel(
Hits,
GetActorLocation(),
GetActorLocation() + GetActorForwardVector() * 500.f,
FQuat::Identity,
ECC_Pawn,
Capsule,
Params
);
for (const FHitResult& Hit : Hits)
{
if (AActor* HitActor = Hit.GetActor())
{
UE_LOG(LogTemp, Log, TEXT("Hit: %s (blocking: %s)"),
*HitActor->GetName(),
Hit.bBlockingHit ? TEXT("yes") : TEXT("no"));
}
} See Also
Tags
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?