RealDocs

UKismetSystemLibrary::LineTraceMultiForObjects

function Engine Blueprint Since 4.0
#include "Kismet/KismetSystemLibrary.h"
Access: public Specifiers: staticBlueprintCallable

Description

Traces a line from Start to End and returns every hit against components whose collision responds to one of the given Object Types. Exposed to Blueprint as 'Multi Line Trace For Objects'.

Caveats & Gotchas

  • ObjectTypes is the same classification system used by overlap queries (SphereOverlapActors, etc.), so an actor invisible to a Trace Channel query can still show up here if its Object Type matches.
  • OutHits contains every matching component along the full line, not just up to a blocking hit — a long line through several dynamic actors returns all of them in one call.
  • This has no TraceChannel parameter at all, so channel-based collision responses (Block/Overlap/Ignore) never factor into the result — only the Object Type list does.

Signature

static ENGINE_API bool LineTraceMultiForObjects(const UObject* WorldContextObject, const FVector Start, const FVector End, const TArray<TEnumAsByte<EObjectTypeQuery> > & ObjectTypes, 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* World context.
Start const FVector Start of the line segment.
End const FVector End of the line segment.
ObjectTypes const TArray<TEnumAsByte<EObjectTypeQuery>>& Array of Object Types to trace against.
bTraceComplex bool True to test against complex collision, false to test against simplified collision.
ActorsToIgnore const TArray<AActor*>& Actors to exclude from the trace.
DrawDebugType EDrawDebugTrace::Type Debug draw mode.
OutHits TArray<FHitResult>& All hits found along the line.
bIgnoreSelf bool Whether to ignore the world context actor itself.
TraceColor FLinearColor Debug draw color for the trace. FLinearColor::Red
TraceHitColor FLinearColor Debug draw color for hits. FLinearColor::Green
DrawTime float How long the debug draw persists, in seconds. 5.0f

Return Type

bool

Example

Find every pawn and physics body along a line C++
TArray<FHitResult> Hits;
TArray<TEnumAsByte<EObjectTypeQuery>> ObjectTypes;
ObjectTypes.Add(UEngineTypes::ConvertToObjectType(ECC_Pawn));
ObjectTypes.Add(UEngineTypes::ConvertToObjectType(ECC_PhysicsBody));

TArray<AActor*> ActorsToIgnore;
ActorsToIgnore.Add(this);

const FVector Start = GetActorLocation();
const FVector End = Start + GetActorForwardVector() * 1000.f;

bool bHit = UKismetSystemLibrary::LineTraceMultiForObjects(this, Start, End, ObjectTypes, false, ActorsToIgnore, EDrawDebugTrace::ForDuration, Hits, true);

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.