UKismetSystemLibrary::CapsuleTraceSingleByProfile
#include "Kismet/KismetSystemLibrary.h"
Access: public
Specifiers: staticBlueprintCallable
Description
Sweeps a capsule from Start to End against the world using a named Collision Profile and returns the first blocking hit. Exposed to Blueprint as 'Capsule Trace By Profile'.
Caveats & Gotchas
- • This is commonly used with the 'Pawn' profile to replicate a character's own capsule collision behavior when test-moving or checking a proposed location before teleporting.
- • HalfHeight follows UCapsuleComponent's center-to-hemisphere-tip convention, same as the other capsule trace overloads — passing a raw cylinder height understates the actual swept volume.
- • There's no Orientation parameter here either, so the capsule always sweeps upright along world/actor Z regardless of the profile used.
Signature
static ENGINE_API bool CapsuleTraceSingleByProfile(const UObject* WorldContextObject, const FVector Start, const FVector End, float Radius, float HalfHeight, 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. | — |
| Radius | float | Radius of the capsule to sweep. | — |
| HalfHeight | float | Distance from the center of the capsule to the tip of a hemisphere endcap. | — |
| 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 capsule to validate a teleport destination against Pawn collision C++
FHitResult Hit;
TArray<AActor*> ActorsToIgnore;
ActorsToIgnore.Add(this);
const FVector Start = GetActorLocation();
const FVector End = ProposedTeleportLocation;
bool bHit = UKismetSystemLibrary::CapsuleTraceSingleByProfile(this, Start, End, 34.f, 88.f, FName("Pawn"), false, ActorsToIgnore, EDrawDebugTrace::ForDuration, Hit, true); See Also
Tags
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?