How to check if an Actor is nearby in Unreal Engine

- by

Unreal Engine has two handy functions called Get Horizontal Distance To and Get Vertical Distance To. These can be used to see if an actor is in range of something else. Here’s a quick example on how to use them.

Imagine a drone that we shoot from a distance, and a blast radius that would happen if our player is nearby. In the explosion routine of the drone, we can apply damage to our player, but check if they’re near enough like this:

Goal Actor is my player, “self” in the drone, and we’re getting the horizontal distance to them. If it’s smaller than 4000 (I’m not sure what unit, atoms perhaps), then we apply damage. If not, nothing happens and the explosion can continue (make sure to connect the false branch, which isn’t shown in the above screenshot).

Get Vertical Distance To works the same, but checks for up/down distance. If our drone could be overhead, or on our height, we may have to check both. Consider this for a full up/down/left/right “in range” check:



If you enjoy my content, please consider supporting me on Ko-fi. In return you can browse this whole site without any pesky ads! More details here.

2 thoughts on “How to check if an Actor is nearby in Unreal Engine”

Leave a Comment