RealDocs

UKismetSystemLibrary::CapsuleTraceMultiByProfile

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

Description

Sweeps a capsule against the world using a collision profile rather than a trace channel or object type, returning every overlap and the first blocking hit sorted along the sweep.

Caveats & Gotchas

  • Results are sorted by distance along the sweep, and the blocking hit (if one exists) is always the last element of OutHits — earlier elements are overlaps only.
  • Collision profile names are validated at edit time in the Blueprint dropdown, but a bad FName passed from C++ silently resolves to no valid profile and the trace hits nothing.
  • DrawDebugType only produces visible output in non-shipping builds; the function is a no-op for drawing purposes in Shipping.

Signature

static bool CapsuleTraceMultiByProfile(const UObject* WorldContextObject, const FVector Start, const FVector End, float Radius, float HalfHeight, 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 used to resolve which world to trace in.
Start const FVector Start of the capsule sweep.
End const FVector End of the capsule sweep.
Radius float Radius of the capsule.
HalfHeight float Distance from the capsule center to the tip of each hemisphere cap.
ProfileName FName Collision profile to test against instead of an object type or trace channel.
bTraceComplex bool True to trace against complex collision (per-poly), false to use simple collision.
ActorsToIgnore const TArray<AActor*>& Actors excluded from the sweep.
DrawDebugType EDrawDebugTrace::Type Whether and how long to draw the trace in the world for debugging.
OutHits TArray<FHitResult>& Sorted hit results along the sweep; the blocking hit, if any, is last.
bIgnoreSelf bool If true, the actor that owns WorldContextObject is excluded from results.
TraceColor FLinearColor Line color used when DrawDebugType draws non-hit segments. FLinearColor::Red
TraceHitColor FLinearColor Line color used when DrawDebugType draws hit segments. FLinearColor::Green
DrawTime float How long the debug draw persists, in seconds. 5.0f

Return Type

bool

Example

Sweep capsule by profile in C++ C++
TArray<FHitResult> Hits;
TArray<AActor*> IgnoreActors;
IgnoreActors.Add(this);

UKismetSystemLibrary::CapsuleTraceMultiByProfile(
    this,
    GetActorLocation(),
    GetActorLocation() + FVector(0, 0, -500),
    34.f, 88.f,
    FName(TEXT("Pawn")),
    false,
    IgnoreActors,
    EDrawDebugTrace::ForDuration,
    Hits,
    true);

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

Version History

Introduced in: 4.19

Version Status Notes
5.6 stable

Feedback

Was this helpful?

Suggest an edit

Select a field above to begin editing.