UKismetSystemLibrary::BoxTraceMultiByProfile
#include "Kismet/KismetSystemLibrary.h"
Access: public
Specifiers: staticBlueprintCallable
Description
Sweeps an oriented box 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 Box Trace By Profile'.
Caveats & Gotchas
- • Testing stops once the single closest blocking result is found — this is not the same as BoxTraceMultiForObjects, which has no early-out and always returns every match.
- • OutHits is sorted with the blocking hit (if any) last; treat all earlier entries as overlaps rather than assuming they're blocking.
- • HalfSize takes the same half-extent convention as the by-channel and for-objects overloads, so existing box dimensions can be reused directly when swapping between them.
Signature
static ENGINE_API bool BoxTraceMultiByProfile(const UObject* WorldContextObject, const FVector Start, const FVector End, FVector HalfSize, const FRotator Orientation, 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. | — |
| HalfSize | FVector | Distance from the center of the box along each axis. | — |
| Orientation | const FRotator | Orientation of the box. | — |
| 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 box using a custom Vehicle profile 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::BoxTraceMultiByProfile(this, Start, End, HalfSize, GetActorRotation(), FName("Vehicle"), 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?