I’m trying to have an object be a specific size when at point A but another specific size at point B and linearly interpolate between those sizes when moved.

I’m thinking about having the algorithm’s return type be a Vector3 so I can just do this:

`transform.localScale = algorithm;`

I know this is more of a math question than anything else but I couldn’t find any site featuring a forum for math problems so I just posted here.

To linearly interpolate between two 3d points, you need to calculate the vector difference between your two points. This is easy: **V** = **B**-**A**

Once you know this, you move from **A** to **B** as a percentage of the difference vector. For example, the halfway point between **A** and **B** would be : **H** = **A** + 0.5 **V**

This can be applied to scale also, since it’s represented by a Vector3.

If you want to change the scale based on the distance traveled from **A** to **B**, you have to calculate what percentage of the distance has been traveled. You can do this using the *Vector3.Distance* function.

```
percentTraveled = Vector3.Distance( A, currentPosition ) / Vector3.Distance( A, B );
```

Once you know this, just linearly interpolate between the initial scale and final scale using *Vector3.Lerp*.

```
scale = Vector3.Lerp( initialScale, finalScale, percentTraveled );
```