Whats the best way to get the Distance between two Vector3?

I know that the best way to get the distance for a Vector3 is using Vector3.distance, etc, etc.
But what I’m looking for here, is how to get the Distance between the two “local X axis” for both Vector3 and their rotations.
I don’t know how to explain this so well, so I made this image:

19413-distance.png

I want to know the “gap” between these two positions, for exemple.
Both are facing the same way, and have the same Y position ( are on the same height )
So they differ on the X and Z axis.
I want to get the distance between them using a perpendicular axis.
Ahn, I really dont know how to write this down, but I guess you guys understood…

I know how to do this using global values, for exemple, the global X axis or Z, like the first image, but I need them to be rotated, how do I do this?

Vector projection is what you are looking for. It’ll take the vector between the two positions and then you can constrain that vector to the XZ plane (or whichever plane you like).

Not sure what the end result you want is, but: Often converting to local space of one object can help. Standard practice for people who do this sort of math. From memory:

vector3 p2 = thing1.InverseTransformDirection(thing2.position - thing1.position);

Math notes: t1-t1 a the world direction. ITD turns a world into a local direction.

In the second picture, p2 is now something like (12,0,-2). Where 12 is the long “thing1 x” line you drew, and -2 is the distance backwards to the tip. In other words, how to find things2, starting from thing1 and using it’s RGB arrows.