UKismetSystemLibrary::BoxTraceMulti
#include "Kismet/KismetSystemLibrary.h"
Access: public
Specifiers: staticBlueprintCallable
Description
Sweeps an oriented box 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 Box Trace By Channel'.
Caveats & Gotchas
- • OutHits is sorted along the trace; only the last entry is guaranteed to be a blocking hit, everything before it is a non-blocking overlap.
- • Orientation applies to the full sweep, so a box that looks axis-aligned in the editor may sweep diagonally if the actor's rotation isn't identity.
- • As with all Multi trace variants, bTraceComplex against dense static meshes is significantly more expensive than the simple-collision path — profile before using it in per-tick logic.
Signature
static ENGINE_API bool BoxTraceMulti(const UObject* WorldContextObject, const FVector Start, const FVector End, FVector HalfSize, const FRotator Orientation, 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. | — |
| HalfSize | FVector | Distance from the center of the box along each axis. | — |
| Orientation | const FRotator | Orientation of the box. | — |
| 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 box and gather all overlapping hits C++
TArray<FHitResult> Hits;
TArray<AActor*> ActorsToIgnore;
ActorsToIgnore.Add(this);
const FVector Start = GetActorLocation();
const FVector End = Start + GetActorForwardVector() * 300.f;
const FVector HalfSize(50.f, 25.f, 25.f);
bool bHit = UKismetSystemLibrary::BoxTraceMulti(this, Start, End, HalfSize, GetActorRotation(), UEngineTypes::ConvertToTraceType(ECC_Visibility), 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?