and I tried changing the time values, but I never got my expected lerp in .2s since I don’t know precisely how this multiplier is working, or what the time in the lerp function represents exactly. I hope anyone can let me know. Thanks
As an aside question, the blogger in this article said that when using lerp, sometimes the movement gets stuttery and jerky in the editor, and indeed it happened to me as well:
As he said, it works great (smoothly) in the build. But I wonder if you (or anyone) know of a fix to this, because mostly all the testing is done in the editor, and it doesn’t feel great to deal with this stuttery movement all the time. Thanks
@Kurt-Dekker Quick question. I want to try your implementation, but it says that only the desiredQuantity has to be set. What if I want this smooth transition to happen in 0.2 seconds, which other value should I modify?
EDIT: Maybe I should set this const float MovementPerSecond = 2.0f; value to 0.2f?
What’s the point of the Time.deltaTime multiplication at the end? It makes no sense, remove it
ps: your code would not compile as you have two opening brackets in that line of code and just one closing. So this does not add up.
pps: this line of code is correct, but will make the transtion last for 2 seconds:
time += 0.5f * Time.deltaTime;
The overall logic would be
time += Time.deltaTime / duration;
So if you want the transition to last 0.2f seconds, just set duration to 0.2f. Though dividing by 0.2 is the same as multiplying by 5. So you could also do
It’s needed in this case because I’m computing the velocity right there; then in my Move() method I just do transform.Translate(velocity); (so the Time.deltaTime is calculated earlier)
Probably I made a typo while writing the code here from scratch, sorry about that!
Thank you for letting me know how that “time” from the Unity’s example works! that was very instructive, I’ll give it a try.
PS: do you know why this provokes the stuttery movement in the Editor?