# Difference in Vector3s, as a Vector 3.(Distance)

I’ve been trying and searching for a while for the best way to code something that I think is quite simple. I want to calculate the distance between 2 objects, but it must return a Vector3.

I realize I can just compare the individual axes and combine them into a new Vector3, but I’m wondering if there is a more efficient way.

How do you find the difference between 5 and 2?

``````var diff = 5 - 2;
``````

How do you find the difference between two Vector3 values?

``````var diff = v2 - v1; //vector from v1 to v2
``````

For questions like this, it sometimes helps me to think of regular numbers as a sort of “one-dimensional vector” on a number line.

Notice, of course, that the order of your inputs matters. `(2-5)` is different from `(5-2)`, just like `(v1-v2)` is different from `(v2-v1)`. When in doubt, draw a picture and figure out which direction you want the result to point in.

Given Object1 and Object2 as transforms, you can do:

`````` var delta = Object2.positon - Object1.position;
``````

Note that the individual components (x,y,z) will be signed, and measured starting from Object1. The total distance (unsigned) can be had from delta.magnitude;