RealDocs

AActor::ActorLineTraceSingle

function Engine Since 4.0
#include "GameFramework/Actor.h"
Access: public

Description

Traces a ray against only the components of this specific actor and returns the first blocking hit. Unlike a world line trace, this ignores all other actors.

Caveats & Gotchas

  • This only tests components of this actor — it does not query the rest of the world. Use UWorld::LineTraceSingleByChannel() when you need a full scene trace.
  • Only blocking hits are returned. Overlap-only collision responses will not produce a hit result even if geometrically intersecting.

Signature

ENGINE_API bool ActorLineTraceSingle(struct FHitResult& OutHit, const FVector& Start, const FVector& End, ECollisionChannel TraceChannel, const struct FCollisionQueryParams& Params) const

Parameters

Name Type Description Default
OutHit struct FHitResult& Output containing the first blocking hit found.
Start const FVector& World space start point of the ray.
End const FVector& World space end point of the ray.
TraceChannel ECollisionChannel The collision channel to test against.
Params const struct FCollisionQueryParams& Additional trace parameters such as actors to ignore.

Return Type

bool

Example

Trace against a specific actor's mesh C++
FHitResult HitResult;
FCollisionQueryParams Params;
Params.AddIgnoredActor(this); // Ignore self

if (TargetActor->ActorLineTraceSingle(HitResult, AimStart, AimEnd, ECC_Visibility, Params))
{
    FVector ImpactPoint = HitResult.ImpactPoint;
    // Use impact point for hit FX, damage location, etc.
}

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.