RealDocs

UKismetSystemLibrary::BoxTraceSingleByProfile

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 world using a named Collision Profile and returns the first blocking hit. Exposed to Blueprint as 'Box Trace By Profile'.

Caveats & Gotchas

  • • Orientation still applies the full box rotation regardless of the profile-based filtering — an axis-aligned HalfSize with a non-identity Orientation still sweeps at that angle.
  • • The profile determines the full response matrix at once, so a box that would block on one channel and overlap on another (under the by-channel functions) resolves to a single outcome dictated by the profile.
  • • As with LineTraceSingleByProfile, an unrecognized ProfileName doesn't produce a compile or Blueprint-time error — verify the exact name against Project Settings > Collision.

Signature

static ENGINE_API bool BoxTraceSingleByProfile(const UObject* WorldContextObject, const FVector Start, const FVector End, const FVector HalfSize, const FRotator Orientation, UPARAM(Meta=(GetOptions=GetCollisionProfileNames)) FName ProfileName, 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. —
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. —
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 box using a custom Interactable profile 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::BoxTraceSingleByProfile(this, Start, End, HalfSize, GetActorRotation(), FName("Interactable"), 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.