title: How to achieve smooth movement on an object locked on the Y-axis following mouse position?
body: <p>I am making an Android game in LibGDX, where the player object will move accordingly to the touch Y-position with a smooth movement, making it look like it is following the touch movement. This is my code so far, it does as supposed to, but it isn't smooth enough and sometimes it "wiggles" upon reaching the touch position (it isn't reaching distance zero, but bypasses it.):</p>
  
  <pre><code>if ((player.getPosition().y * world.ppuY) &lt; (world.height-touch.y-(world.ppuY/2f))) { //if player is below touch
              if (Math.abs((player.getPosition().y * world.ppuY)-(world.height-touch.y-(world.ppuY/2f))) &gt; 20) { // if distance is more than 20
                  player.getVelocity().y = Math.min(
                      Math.abs(
                          ((player.getPosition().y * world.ppuY)-(world.height-touch.y-(world.ppuY/2f)))/2f), 
                      Player.SPEED); // set velocity
              } else { // if distance is less than 20
                  if (player.getVelocity().y != 0)
                      player.getVelocity().y *= 0.3f+delta; // slow down velocity
                  else
                      player.getVelocity().y = Math.min(
                          Math.abs(
                              ((player.getPosition().y * world.ppuY)-(world.height-touch.y-(world.ppuY/2f)))/2f), 
                          Player.SPEED); // just so it follows even when the touch moves slightly
              }
          }
  
  if ((player.getPosition().y * world.ppuY) &gt; (world.height-touch.y-(world.ppuY/2f))) {
              if (Math.abs((player.getPosition().y * world.ppuY)-(world.height-touch.y-(world.ppuY/2f))) &gt; 20) {
                  player.getVelocity().y = -Math.min(
                      Math.abs(
                          ((player.getPosition().y * world.ppuY)-(world.height-touch.y-(world.ppuY/2f)))/2f),
                      Player.SPEED);
              } else {
                  if (player.getVelocity().y &gt; 1) {
                      player.getVelocity().y *= 0.3f+delta;
                  } else {
                          player.getVelocity().y = -Math.min(
                          Math.abs(
                              ((player.getPosition().y * world.ppuY)-(world.height-touch.y-(world.ppuY/2f)))/2f), 
                          Player.SPEED);
                  }
              }
          }
  </code></pre>
  
  <p>Is there a better method than this that firstly makes the code shorter and secondly makes the smooth movement even better and more stable?</p>