How do I effectively use lerp to move an object

0 favourites
  • 2 posts
From the Asset Store
This is a code so you can see the same skin on all screens (peers). Each peer gets a skin, in addition to 4 directions t
  • 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?


  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)