UKismetSystemLibrary::BoxTraceMultiForObjects
#include "Kismet/KismetSystemLibrary.h"
Access: public
Specifiers: staticBlueprintCallable
Description
Sweeps an oriented box from Start to End and returns every hit against components whose collision responds to one of the given Object Types. Exposed to Blueprint as 'Multi Box Trace For Objects'.
Caveats & Gotchas
- • OutHits can include multiple overlapping components per actor if that actor has several primitives each matching an Object Type in the list.
- • There's no TraceChannel or blocking semantics here — every component matching any entry in ObjectTypes is added to OutHits regardless of collision response settings.
- • A large HalfSize combined with bTraceComplex against static meshes is one of the more expensive trace calls in this library — prefer the simple-collision path unless per-triangle accuracy is required.
Signature
static ENGINE_API bool BoxTraceMultiForObjects(const UObject* WorldContextObject, const FVector Start, const FVector End, const FVector HalfSize, const FRotator Orientation, const TArray<TEnumAsByte<EObjectTypeQuery> > & ObjectTypes, 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 | const FVector | Distance from the center of the box along each axis. | — |
| Orientation | const FRotator | Orientation of the box. | — |
| ObjectTypes | const TArray<TEnumAsByte<EObjectTypeQuery>>& | Array of Object Types to trace 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 found along the sweep. | — |
| 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 for every dynamic and physics-body actor C++
TArray<FHitResult> Hits;
TArray<TEnumAsByte<EObjectTypeQuery>> ObjectTypes;
ObjectTypes.Add(UEngineTypes::ConvertToObjectType(ECC_WorldDynamic));
ObjectTypes.Add(UEngineTypes::ConvertToObjectType(ECC_PhysicsBody));
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::BoxTraceMultiForObjects(this, Start, End, HalfSize, GetActorRotation(), ObjectTypes, 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?