UWorld::LineTraceMultiByChannel
#include "Engine/World.h"
Access: public
Specifiers: const
Description
Traces a ray from Start to End and returns all overlapping hits plus the first blocking hit. Results are sorted by distance; the blocking hit (if any) is always the last element. Returns true if OutHits contains any blocking hit.
Signature
bool LineTraceMultiByChannel( TArray<struct FHitResult>& OutHits, const FVector& Start, const FVector& End, ECollisionChannel TraceChannel, const FCollisionQueryParams& Params = FCollisionQueryParams::DefaultQueryParam, const FCollisionResponseParams& ResponseParam = FCollisionResponseParams::DefaultResponseParam ) const Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| OutHits | TArray<struct FHitResult>& | Receives all hit results sorted by distance. The blocking hit (if any) is always the last element. | — |
| Start | const FVector& | World-space start point of the ray. | — |
| End | const FVector& | World-space end point of the ray. | — |
| TraceChannel | ECollisionChannel | Collision channel used to determine which components are hit. | — |
| Params | const FCollisionQueryParams& | Additional query options including ignored actors. | FCollisionQueryParams::DefaultQueryParam |
| ResponseParam | const FCollisionResponseParams& | Override collision response settings. | FCollisionResponseParams::DefaultResponseParam |
Return Type
bool Caveats & Gotchas
- • The trace stops generating results after the first blocking hit — geometry behind the blocker is not tested.
- • OutHits contains both overlapping and blocking hits. Check FHitResult::bBlockingHit on each result to distinguish them.
- • OutHits is not cleared before use — clear it yourself if the array is reused across calls.
Example
Trace through multiple overlapping actors C++
TArray<FHitResult> Hits;
FCollisionQueryParams Params;
Params.AddIgnoredActor(this);
GetWorld()->LineTraceMultiByChannel(Hits, Start, End, ECC_Visibility, Params);
for (const FHitResult& Hit : Hits)
{
if (Hit.bBlockingHit)
{
// First (and only) blocker
}
} Tags
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?