RealDocs

AActor::GetHorizontalDotProductTo

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

Description

Returns the dot product between this actor's forward vector and the horizontal (XY-plane) direction to OtherActor. Ignores Z, making it reliable for checking whether an actor is facing another on flat ground.

Caveats & Gotchas

  • Returns -2.0 on failure and 0.0 for coincident actors — always guard against -2.0 before interpreting the result as a real angle.
  • Flattens both vectors to 2D before computing, so vertical offset between actors is ignored entirely. If you need to account for pitch (e.g., a turret aiming up), use GetDotProductTo instead.

Signature

ENGINE_API float GetHorizontalDotProductTo(const AActor* OtherActor) const;

Parameters

Name Type Description Default
OtherActor const AActor* The other actor to compute the horizontal dot product toward.

Return Type

float

Example

Simple field-of-view check on the XY plane C++
float HDot = Guard->GetHorizontalDotProductTo(Player);
if (HDot != -2.f && HDot > FMath::Cos(FMath::DegreesToRadians(60.f)))
{
    Guard->AlertToPlayer(Player);
}

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.