You’re moving the object using Vector3.Lerp()
. When you move with linear interpolation (lerp), the speed is constant. To add speed up at the beginning or slow down at the end, you’d need to use easing.
Ironically the source you obtained this code from seems to have left a comment referencing easing but then forgotten to actually include the easing section.
There are many ways to implement easing. One way is to use easing functions. You can search the web to find free libraries of easing functions for Unity. You’d generally use them something like this:
var t = passedTime / duration;
var lerpFactor = EasingLibrary.EaseInOutCubic(t);
transform.position = Vector3.Lerp(currentPosition, currentWaypoint.position, lerpFactor);
Another solution is to use an Animation Curve. With this approach, you’d declare a curve field at the top of your script:
(SerializeField) private AnimationCurve easingCurve;
This will show a curve field in the Inspector. We’ll use this curve to define the interpolated motion of our GameObject. Start with something like this (note that the curve should start at (0,0) and end at (1,1):

Then we’ll use the curve in our movement coroutine:
do {
var t = passedTime / duration;
var lerpFactor = easingCurve.Evaluate(t); //use the curve to apply easing
transform.position = Vector3.Lerp(currentPosition, currentWaypoint.position, lerpFactor);
passedTime += Time.deltaTime;
yield return null;
} while (passedTime <= duration);
Our curve defines a function which takes an input and returns an output. The “time” (x-axis) of the curve represents the input (in our case, a time from 0 – 1) and the “value” (y-axis) represents the corresponding output (in our case, how far the GameObject has moved between the start and end positions).
If the curve was a perfectly straight line from (0,0) to (1,1) the output would be linear (in fact, it would be exactly the same value as the input). However, this s-shaped curve will ease the motion in at the beginning and ease it out at the end. The flatter the curve is in a particular area, the slower our motion will be at that time.
If you find this confusing, try messing around with the shape of the curve and study how this affects the animation.
Easing functions usually are easier to use. If there’s a specific style of easing that you want, you would just call the appropriate function. Animation curves take a little more work to set up but give you more control over the exact motion.
For a project which makes heavy use of easing, I’ll usually rely on an easing library and only use an animation curve if the easing functions don’t give me enough fine control. If I only need to use easing in one or two places, I’ll usually just use an animation curve rather than adding an easing library to the project.