RealDocs

UKismetSystemLibrary::SphereTraceMultiByProfile

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

Description

Sweeps a sphere from Start to End against the world using a named Collision Profile and returns all overlapping hits plus the first blocking hit. Exposed to Blueprint as 'Multi Sphere Trace By Profile'.

Caveats & Gotchas

  • Only the single closest blocking result is generated — testing stops there, so anything further along the sweep behind a blocking hit is never reported.
  • OutHits sorts overlaps first with the blocking hit (if found) last, matching the same convention as the other Multi trace functions in this library.
  • The result depends on the profile's configured responses for every object it encounters, which makes this call harder to reason about in isolation than SphereTraceMulti's single explicit TraceChannel.

Signature

static ENGINE_API bool SphereTraceMultiByProfile(const UObject* WorldContextObject, const FVector Start, const FVector End, float Radius, UPARAM(Meta=(GetOptions=GetCollisionProfileNames)) FName ProfileName, 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.
ProfileName FName The collision profile used to determine which components to hit.
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 against a custom Ragdoll profile C++
TArray<FHitResult> Hits;
TArray<AActor*> ActorsToIgnore;
ActorsToIgnore.Add(this);

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

bool bHit = UKismetSystemLibrary::SphereTraceMultiByProfile(this, Start, End, 30.f, FName("Ragdoll"), 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.