UKismetSystemLibrary::LineTraceSingleByProfile
#include "Kismet/KismetSystemLibrary.h"
Access: public
Specifiers: staticBlueprintCallable
Description
Traces a line from Start to End against the world using a named Collision Profile and returns the first blocking hit. Exposed to Blueprint as 'Line Trace By Profile'.
Caveats & Gotchas
- • ProfileName must exactly match a profile defined in Project Settings > Engine > Collision (or a project's DefaultEngine.ini); it evaluates that profile's whole response template rather than a single channel.
- • GetCollisionProfileNames, which populates the Blueprint dropdown's valid options, only exists in WITH_EDITOR builds — the dropdown is an editor convenience, not a runtime check, so a typo'd FName still compiles and runs.
- • This uses the profile's full collision response matrix, so it can hit or ignore things that neither LineTraceSingle (by channel) nor LineTraceSingleForObjects (by object type) would, depending on how the profile is configured.
Signature
static ENGINE_API bool LineTraceSingleByProfile(const UObject* WorldContextObject, const FVector Start, const FVector End, UPARAM(Meta=(GetOptions="Engine.KismetSystemLibrary.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 line segment. | — |
| End | const FVector | End of the line segment. | — |
| 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
Line trace using the built-in BlockAll profile C++
FHitResult Hit;
TArray<AActor*> ActorsToIgnore;
ActorsToIgnore.Add(this);
const FVector Start = GetActorLocation();
const FVector End = Start + GetActorForwardVector() * 1000.f;
bool bHit = UKismetSystemLibrary::LineTraceSingleByProfile(this, Start, End, FName("BlockAll"), 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?