RealDocs

AActor::GetHorizontalDistanceTo

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

Description

Returns the 2D (horizontal) distance between this actor and OtherActor, ignoring Z height. Useful for ground-plane proximity checks where vertical offset should not matter.

Caveats & Gotchas

  • Performs a square root internally, making it more expensive than GetSquaredHorizontalDistanceTo. Use the squared version when comparing distances in tight loops.
  • Does not guard against a null OtherActor — passing null will crash.

Signature

ENGINE_API float GetHorizontalDistanceTo(const AActor* OtherActor) const;

Parameters

Name Type Description Default
OtherActor const AActor* The other actor to measure horizontal distance to.

Return Type

float

Examples

Print a message when an NPC is within 150 units horizontally Blueprint
Event Tick Delta Seconds Delta Seconds Branch Condition Condition True False Print String In String NPC in range! NPC in range! Get Horizontal Distance To Target is Actor Other Actor Return Value < A B 150.0 150.0 Return Value Return Value NPC NPC
Edit Blueprint graph Print a message when an NPC is within 150 units horizontally
Drag node headers to move · Drag from an output pin to an input pin to connect · Scroll to zoom · Right-click for actions
Check if NPC is within interaction range ignoring height C++
if (NPC->GetHorizontalDistanceTo(Player) < 150.f)
{
    NPC->StartDialogue();
}

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.