RealDocs

UKismetSystemLibrary::SphereTraceMulti

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

Description

Sweeps a sphere of the given Radius from Start to End against the given Trace Channel and returns every hit encountered, including overlaps before the first blocking hit. Exposed to Blueprint as 'Multi Sphere Trace By Channel'.

Caveats & Gotchas

  • OutHits is sorted along the trace from Start to End — only the last element is guaranteed to be a blocking hit; earlier entries are non-blocking overlaps and may include actors that never actually stop the sweep.
  • bTraceComplex traces against per-triangle collision instead of the simplified collision body — much more expensive, so avoid it every frame on complex static meshes.
  • DrawDebugType visualization only shows up in non-shipping builds compiled with ENABLE_DRAW_DEBUG; it silently no-ops in shipping.

Signature

static ENGINE_API bool SphereTraceMulti(const UObject* WorldContextObject, const FVector Start, const FVector End, float Radius, 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* World context.
Start const FVector Start of the sweep.
End const FVector End of the sweep.
Radius float Radius of the sphere to sweep.
TraceChannel ETraceTypeQuery The trace channel to test 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, sorted from Start to End; the blocking hit (if any) is last.
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

Sweep a sphere and collect every overlapping actor C++
TArray<FHitResult> Hits;
TArray<AActor*> ActorsToIgnore;
ActorsToIgnore.Add(this);

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

bool bHit = UKismetSystemLibrary::SphereTraceMulti(this, Start, End, 40.f, UEngineTypes::ConvertToTraceType(ECC_Visibility), false, ActorsToIgnore, EDrawDebugTrace::ForDuration, Hits, true);

for (const FHitResult& Hit : Hits)
{
	UE_LOG(LogTemp, Log, TEXT("Hit: %s"), *Hit.GetActor()->GetName());
}

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.