Move object to position

Hi all.
How to move an object to a position at a certain speed.
Now I do this:
it works, but if you increase the speed, the object flies by and it is logical.
I’m sure there’s a better method to stop the object exactly where I need it. But I don’t know how.


function move(speed) {
  var d = mesh.position.x - mesh2.position.x;
  if (mesh.position.x > mesh2.position.x) {
    mesh.position.x -= Math.min( speed, d );

Thank you so much!

A more advanced approach to solve this issue are “steering behaviors”. This technique comes from game development and allows you to model the steering and movement of game entities in a more realistic fashion. The so called “Arrive” behavior allows a game entity to move to a certain target position. However, it does not overshoot or stop abruptly. Instead, it decelerates and performs a gentle halt. The amount of deceleration is a configurable property of the behavior.