# no slow down towards end of lerp /linear_interpolate

Attention Topic was automatically imported from the old Question2Answer platform.

I am currently testing out lerp and linear_interpolate for movement.
I know there are other method to move a node,but I am just testing out different stuff.
I notice that there is a slow down as the node close to the destination. Is there a way to do it so the movement speed is the same all the way ?

Alright…I dig a little deeper. This is what I found

``````
timelerped += delta
position = position.linear_interpolate(targetPos,timelerped / timetolerp)
``````

to use this , you do need to know how long you want the obj to move to destination
which is time = distance / speed. It kinda works for what I wanted to do.
Just in case anyone needing this

Using a Tween node is probably more suited in most cases

Calinou | 2019-04-12 21:39

You need to keep track of how far you’ve gone through the motion. Basically, you need to keep track of

• where you started: `origin`
• where you want to end up: `target`
• when you started: `start`
• how long you want to take: `duration`
• current time: `now`

If you have all that information, you can do

``````origin.linear_interpolate(target, (now - start) / duration)
``````

(Assuming `now`, `start`, and `duration` are all the same unit of time (most likely seconds).)

If you keep track of how long it has been since you started (`offset`) instead of start time and current time, you can shorten it to

``````origin.linear_interpolate(target, offset / duration)
``````

NOTE: It’s important that you do not use the current position. You need to store your starting position and lerp between that and the target. Lerping from your current position is great for smooth dampening using a constant offset:

``````position = position.linear_interpolate(target, 0.9)
``````

Thanks , this made a lot of sense to me. I am gonna try it out later. Not by my pc at the moment

lowpolygon | 2019-04-12 22:58

Thanks this help me out.

morningkingdom | 2021-03-30 18:32