Comments and answers for "Can you help me make an algorithm out of these parameters?"
http://answers.unity.com/questions/1161098/can-you-help-me-make-an-algorithm-out-of-these-spe.html
The latest comments and answers for the question "Can you help me make an algorithm out of these parameters?"Comment by PlayCreatively on PlayCreatively's answer
http://answers.unity.com/comments/1161279/view.html
Thanks! I hadn't thought about using the Vector3.Lerp for anything else but interpolating between locations. I did play around with Vector3.Lerp but in my instance it didn't interpolate correctly and just kept expanding instead of keeping its size according to the t in `Vector3.Lerp(vector3 A, vector3 B, float t)`
so that made me think that the t was the speed of the interpolation, clearly one of my variables in Vector3.Lerp was uncontrollably expanding instead of being constant like it should have.
However, it works now!Sat, 26 Mar 2016 17:23:01 GMTPlayCreativelyAnswer by LazyElephant
http://answers.unity.com/answers/1161129/view.html
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 );Sat, 26 Mar 2016 08:11:57 GMTLazyElephant