How do I effectively use lerp to move an object

Get help using Construct 2

Post » Sun Jan 04, 2015 6:54 pm

Hi guys.
I have a problem with lerp.
I have two objects that I've managed to successfully move towards a designated position using lerp.

Using Set Position I have:

Where Blocks.X and Blocks.Y are the X and Y coordinates to the object to move and Den.ImagePointX(0) and Den.ImagePointY(0) are the coordinates of the target destination. 0.01 seems to be a good speed at which to move my objects. Unless I've missed something.

Anyway, my problem is, my moving objects never seem to actually reach their destination.
It looks to me like the distance between the moving objects is calculated, moved slightly, then the distance is calculated again.... Over a brief time, the moving objects get slower and slower and the distance travelled on each click is less and less.

What have I done wrong?

Posts: 33
Reputation: 341

Post » Sun Jan 04, 2015 7:05 pm

Well, lerp is like saying "move 1% of current values towards this value" so over time that 1% becomes smaller, so it moves ever slower.

This makes a nice ease in or out effect,but as you see can lack precision.

Also using 0.01 is a bad idea, you should use dt or a form of dt/5 or such.

You could use a 3rd party "move to" behavior that can be found here, I hear it's neat.
Posts: 1,101
Reputation: 5,646

Return to How do I....?

Who is online

Users browsing this forum: darkrealos, plinkie, Rhindon and 20 guests