UKismetSystemLibrary::LineTraceMulti
#include "Kismet/KismetSystemLibrary.h"
Access: public
Specifiers: staticUFUNCTIONBlueprintCallable
Description
Performs a line trace between Start and End against the given Trace Channel and returns every hit up to and including the first blocking hit. Exposed to Blueprint as 'Multi Line Trace By Channel'.
Caveats & Gotchas
- • If the segment never encounters a blocking hit, OutHits contains every overlapping hit for the entire Start-to-End segment, not just up to some implicit range limit.
- • TraceChannel-based like LineTraceSingle — pass a Trace Channel, not an Object Type; use LineTraceMultiForObjects for Object Type queries.
- • DrawDebugType is compiled out entirely in shipping builds (guarded by ENABLE_DRAW_DEBUG).
Signature
static ENGINE_API bool LineTraceMulti(const UObject* WorldContextObject, const FVector Start, const FVector End, ETraceTypeQuery TraceChannel, bool bTraceComplex, const TArray<AActor*>& ActorsToIgnore, EDrawDebugTrace::Type DrawDebugType, TArray<FHitResult>& OutHits, bool bIgnoreSelf, FLinearColor TraceColor = FLinearColor::Red, FLinearColor TraceHitColor = FLinearColor::Green, float DrawTime = 5.0f) Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| WorldContextObject | const UObject* | Object used to resolve which UWorld to run the trace in. | — |
| Start | const FVector | Start point of the trace in world space. | — |
| End | const FVector | End point of the trace in world space. | — |
| TraceChannel | ETraceTypeQuery | Trace Channel to test against (Project Settings > Collision > Trace Channels). | — |
| bTraceComplex | bool | True to test against per-poly complex collision, false to test against simplified collision. | — |
| ActorsToIgnore | const TArray<AActor*>& | Actors excluded from the trace. | — |
| DrawDebugType | EDrawDebugTrace::Type | Debug draw mode for visualizing the trace. | — |
| OutHits | TArray<FHitResult>& | All hits found along the segment, up to and including the first blocking hit. | — |
| bIgnoreSelf | bool | If true, ignores the actor owning WorldContextObject. | — |
| TraceColor | FLinearColor | Color used to draw the non-hit portion of the trace when debug drawing is enabled. | FLinearColor::Red |
| TraceHitColor | FLinearColor | Color used to draw from the hit point onward when debug drawing is enabled. | FLinearColor::Green |
| DrawTime | float | How long the debug draw persists, in seconds. | 5.0f |
Return Type
bool Example
Trace forward and collect every hit up to the first block C++
TArray<FHitResult> Hits;
TArray<AActor*> ActorsToIgnore;
ActorsToIgnore.Add(this);
const FVector Start = GetActorLocation();
const FVector End = Start + GetActorForwardVector() * 1000.f;
bool bHit = UKismetSystemLibrary::LineTraceMulti(this, Start, End, UEngineTypes::ConvertToTraceType(ECC_Visibility), false, ActorsToIgnore, EDrawDebugTrace::ForDuration, Hits, true); Tags
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?