Vector2.Lerp vs. Vector2.SmoothDamp

In my game I have a platform that moves back and forth between two point. I want the movement to be smooth and in a linear motion but with Lerp I noticed if I multiply the 3rd value, the speed, by Time.deltaTime the platform has an acceleration and deceleration movement as it begins to move or reaches the desired point. If I didn’t multiply by Time.deltaTime I had to set the value to 0.02 to have the platform move at a reasonable speed. I stumbled upon Vector2.SmoothDamp but I haven’t much of a chance to check it out but I’m wondering if it is better to use than Vector2.Lerp.

Edit: I used Vector2.SmoothDamp and it works perfect for what I want it to do.

The third argument for Vector2.Lerp() is not speed, it’s the interpolation factor, the percentage of the distance between a and b to return.

To answer your question, smooth motion is exactly what SmoothDamp functions are meant for (or any other non-motion values that should change smoothly), so it would be a good choice. I’m curious to see how you’re currently doing it though, because something sounds off, unless I’m misunderstanding.

I’ll record me using the SmoothDamp and Lerp with and without Time.deltaTime, I’ll edit this reply and add in the link.

Link:

Yes, from your description it is pretty clear you’re not using Lerp correctly. See this article.

You should probably enable interpolation for any rigidbodies you have as well.