RealDocs

UKismetSystemLibrary::BoxTraceSingle

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

Description

Sweeps an oriented box from Start to End against the given Trace Channel and returns the first blocking hit encountered. Exposed to Blueprint as 'Box Trace By Channel'.

Caveats & Gotchas

  • Orientation is a full FRotator applied to the box, not just a yaw — a box rotated 45 degrees on its side will sweep a different silhouette than the same HalfSize with identity rotation.
  • HalfSize is a half-extent per axis, not a full size — passing the same values you'd use for a UBoxComponent's BoxExtent will produce a box twice as large as expected.
  • TraceChannel filters by Trace Channel and each actor's per-channel collision response, not by Object Type — use BoxTraceSingleForObjects if you need to query a category of objects instead.

Signature

static ENGINE_API bool BoxTraceSingle(const UObject* WorldContextObject, const FVector Start, const FVector End, const FVector HalfSize, const FRotator Orientation, ETraceTypeQuery TraceChannel, bool bTraceComplex, const TArray<AActor*>& ActorsToIgnore, EDrawDebugTrace::Type DrawDebugType, FHitResult& OutHit, 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.
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.
OutHit FHitResult& Properties of the trace hit.
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 wide box in front of the actor C++
FHitResult Hit;
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::BoxTraceSingle(this, Start, End, HalfSize, GetActorRotation(), UEngineTypes::ConvertToTraceType(ECC_Visibility), false, ActorsToIgnore, EDrawDebugTrace::ForDuration, Hit, true);

Version History

Introduced in: 4.0

Version Status Notes
5.6 stable

Feedback

Was this helpful?

Suggest an edit

Select a field above to begin editing.