UKismetSystemLibrary::CapsuleTraceMulti
#include "Kismet/KismetSystemLibrary.h"
Access: public
Specifiers: staticBlueprintCallable
Description
Sweeps a capsule 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 Capsule Trace By Channel'.
Caveats & Gotchas
- • OutHits is sorted along the trace from Start to End; only the last entry is guaranteed to be a blocking hit.
- • HalfHeight follows UCapsuleComponent's convention (center to hemisphere tip) — feeding it a cylinder-only height will make the capsule shorter than intended.
- • Like the other Multi variants, this can't early-out once it finds a blocking hit if bTraceComplex forces per-triangle tests on the way — budget accordingly if calling every tick.
Signature
static ENGINE_API bool CapsuleTraceMulti(const UObject* WorldContextObject, const FVector Start, const FVector End, float Radius, float HalfHeight, 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 capsule to sweep. | — |
| HalfHeight | float | Distance from the center of the capsule to the tip of a hemisphere endcap. | — |
| 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 capsule and collect every overlapping actor C++
TArray<FHitResult> Hits;
TArray<AActor*> ActorsToIgnore;
ActorsToIgnore.Add(this);
const FVector Start = GetActorLocation();
const FVector End = Start + GetActorForwardVector() * 200.f;
bool bHit = UKismetSystemLibrary::CapsuleTraceMulti(this, Start, End, 34.f, 88.f, UEngineTypes::ConvertToTraceType(ECC_Pawn), false, ActorsToIgnore, EDrawDebugTrace::ForDuration, Hits, true); See Also
Tags
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?