Comments and answers for "Vector3.Lerp - Constant speed between distance changes"
http://answers.unity.com/questions/746532/vector3lerp-constant-speed-between-distance-change.html
The latest comments and answers for the question "Vector3.Lerp - Constant speed between distance changes"Comment by DavidSof on DavidSof's answer
http://answers.unity.com/comments/1877247/view.html
oo man thank you save my daySat, 18 Dec 2021 21:01:10 GMTDavidSofAnswer by RodrigoSeVeN
http://answers.unity.com/answers/1672172/view.html
Vector3.MoveTowards() is likely the best approach, but here's the answer for Lerp:
float distance = Vector3.Distance(object1.transform.position, object2.transform.position);
float finalSpeed = (distance / newSpeed);
transform.position = Vector3.Lerp(obj1, obj2, Time.deltaTime / finalSpeed);
Dividing **Time.deltaTime** by **distance** makes it move as you wanted.
Dividing **distance** by **newSpeed** changes the speed.
Now just find the best value for newSpeed (might need to increase it a little).Tue, 15 Oct 2019 22:17:04 GMTRodrigoSeVeNComment by $$anonymous$$ on $$anonymous$$'s answer
http://answers.unity.com/comments/1672139/view.html
I haven't figured it quite out yet, but you would need a Mathf.Lerp function for the third MoveTowards parameter.Tue, 15 Oct 2019 21:11:05 GMT$$anonymous$$Answer by Masserz
http://answers.unity.com/answers/892188/view.html
Thanks, I use both:
transform.position = Vector3.MoveTowards (transform.position, other.position, Time.deltaTime * speed / 2);
transform.position = Vector3.Lerp (transform.position, other.position, Time.deltaTime * speed / 2);
to balance the Lerp acceleration and linear effects. Is there a better way of doing this?Tue, 03 Feb 2015 03:41:00 GMTMasserzComment by aanimation on aanimation's answer
http://answers.unity.com/comments/864267/view.html
great..its workingMon, 29 Dec 2014 06:41:08 GMTaanimationComment by Firedan1176 on Firedan1176's answer
http://answers.unity.com/comments/746703/view.html
This is exactly what I was looking for! Thank you.Sat, 12 Jul 2014 13:11:41 GMTFiredan1176Answer by robertbu
http://answers.unity.com/answers/746536/view.html
A solution is to use Vector3.MoveTowards() rather than Vector3.Lerp().
transform.position = Vector3.MoveTowards(transform.position, other.position, Time.deltaTime * speed);
Speed is a variable you define and is measured in units per second. So if you set it to 1.0, your object will move at a constant 1.0 units per second no matter the distance. Note that in this form of MoveTowards, the first parameter must be the current position of the object, not the starting position of the object.Sat, 12 Jul 2014 05:01:01 GMTrobertbu