How to get distance between 2 a simple number?

How can you find out how many blender units / meters / whatever units apart two points are?

For example, I’d like to plug in two objects locations and to get back a float saying how far apart they are (eg 3.816 units).

The obvious choice would seem to be the distance node. For some reason that I have trouble fathoming though, rather than return a simple number, this node returns… a four dimensional vector (!!!)

Alternately, is there a way to use nodes to convert this vector into a simple number representing the distance?

If it can help you, thereafter some code extract of what I use to measure the distance between the end effector of a robot arm and a goal (see here IA, Python and Armory 3d/Blender) and maybe you could reuse :

// Fetch goal
var tr =;
var goal = new iron.math.Vec4();
goal.set(tr.worldx(), tr.worldy(), tr.worldz()); 

var dist:Float = Vec4.distance(goal, effLoc);

1 Like

Thanks! I was hoping for a way with logic nodes, but I’ll try this and see how it works…

Just made a PR for a way to do that in nodes :slight_smile: :

Edit: It just got merged so you can get it with the Armory updater.



@zicklag - You are awesome. Thank you! This is exactly what I needed.

I don’t want to seem ungrateful, but wouldn’t this make more sense to add this into the Get Distance node, rather than the Vector Math node though?

I imagine that anyone looking to get the distance between two points as a float would automatically look at the Get Distance node, rather than a node called “Vector Math”.

If you don’t want to add it to the current Get Distance node, then how about putting it in a new node called “Get Distance (Value)”. The current Get Distance node could be renamed to “Get Distance (Vector)”.

1 Like

Glory to God. :slight_smile:

When I get time, I’ll check that out. :+1: I didn’t know there was a get distance node already. Ping me if I don’t get to this within a couple of weeks or something like that.

1 Like