# Calculating distance from actor/order of appearance

**URL:** <https://forums.unrealengine.com/t/calculating-distance-from-actor-order-of-appearance/403898>\
**Category:** World Creation\
**Tags:** compare, distance, unreal-engine, UE4, Blueprint, question\
**Created:** [September 6, 2017, 2:54pm UTC](https://forums.unrealengine.com/t/calculating-distance-from-actor-order-of-appearance/403898 "2017-09-06T14:54:49Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_519ef7ae](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_519ef7ae](https://forums.unrealengine.com/u/anonymous_user_519ef7ae)\
**Post date:** [September 6, 2017, 2:54pm UTC](https://forums.unrealengine.com/t/calculating-distance-from-actor-order-of-appearance/403898/1 "2017-09-06T14:54:49Z")

</div>

I have three actors stood in a line inside a box trace of a static object. One of the actors is the player pawn and the other two actors are children of a master actor class. What I’m having trouble doing is detecting what order the actors are stood in. I can calculate the distance from two objects by subtracting the locations and breaking the vector to get the Z distance, or I can split the locations and compare the Z locations, but what I can’t seem to figure out is how I compare all locations of each actor that enters the static objects box trace to find the order they are stood in.

What I am trying to do is increase a variable depending on how far away they are from the object. +1 for the closest, +2 for the actor behind the closest, and +3, +4 and so on.

---

<div class="post-metadata">

**Author:** ![wisemethuselah](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@wisemethuselah](https://forums.unrealengine.com/u/wisemethuselah)\
**Post date:** [September 6, 2017, 6:38pm UTC](https://forums.unrealengine.com/t/calculating-distance-from-actor-order-of-appearance/403898/2 "2017-09-06T18:38:04Z")

</div>

Hi, you can just use a node called “get distance to” to get the distance between actors. It returns a float value, then you could compare those using some less thans and make something happen on the result of that. I hope that helps.
