UWorld::ComponentSweepMultiByChannel
#include "Engine/World.h"
Access: public
Specifiers: const
Description
Sweeps a component's actual collision geometry from Start to End on a specified collision channel and returns all hit results. Combines the shape fidelity of ComponentSweepMulti with explicit channel-based filtering.
Caveats & Gotchas
- • PrimComp's world transform is entirely ignored — Start, End, and Rot define the pose used for the sweep.
- • TraceChannel overrides the component's own collision channel for this query only — the component's response table still determines what counts as a block vs overlap.
- • A convenience FRotator overload exists but internally converts to FQuat; prefer the FQuat signature for performance.
- • PrimComp must have valid collision geometry and collision enabled. Components with no collision body will produce no hits.
Signature
bool ComponentSweepMultiByChannel(TArray<struct FHitResult>& OutHits, class UPrimitiveComponent* PrimComp, const FVector& Start, const FVector& End, const FQuat& Rot, ECollisionChannel TraceChannel, const FComponentQueryParams& Params) const Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| OutHits | TArray<struct FHitResult>& | Array populated with all hits found during the sweep. | — |
| PrimComp | class UPrimitiveComponent* | Component whose collision geometry is used for the sweep. Its world transform is ignored. | — |
| Start | const FVector& | World-space start location of the component geometry. | — |
| End | const FVector& | World-space end location of the component geometry. | — |
| Rot | const FQuat& | Rotation applied to the component geometry for the duration of the sweep. | — |
| TraceChannel | ECollisionChannel | The collision channel to use for this query, overriding the component's own channel. | — |
| Params | const FComponentQueryParams& | Additional query parameters such as actors or components to ignore. | — |
Return Type
bool Example
Sweep a box component on ECC_Visibility to check line-of-sight blockage C++
UBoxComponent* Box = FindComponentByClass<UBoxComponent>();
TArray<FHitResult> Hits;
FComponentQueryParams Params;
Params.AddIgnoredActor(this);
bool bBlocked = GetWorld()->ComponentSweepMultiByChannel(
Hits,
Box,
EyeLocation,
TargetLocation,
FQuat::Identity,
ECC_Visibility,
Params
);
if (bBlocked)
{
// first blocking hit is Hits.Last()
UE_LOG(LogTemp, Log, TEXT("Blocked by: %s"), *Hits.Last().GetActor()->GetName());
} Tags
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?