title: LIBGDX Smoothing player movement
body: <p>I have a problem with my game (jumper type game), when a player is falling down or move left/right it isn't smooth, I can see sprite multiple times (like some kind of shadow). After searching the internet I think it's something with deltaTime but I cannot find out how to fix it.
  The code for render method in play screen is:</p>
  
  <pre><code>@Override
  public void render(float delta) {
      Gdx.gl.glClearColor(0,0,0,1);
      Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
  
      //game running
      if(state == RUNNING){
          //make world step
          doPhysicsStep(delta);
      //update player and camera
          player.update(delta);
      if(player.getBody().getPosition().x &lt; bottomLeft.x)
          player.getBody().setTransform(bottomRight.x, player.getBody().getPosition().y, player.getBody().getAngle());
      else if(player.getBody().getPosition().x &gt; bottomRight.x)
          player.getBody().setTransform(bottomLeft.x, player.getBody().getPosition().y, player.getBody().getAngle());
  
      camera.position.y =player.getBody().getPosition().y &gt; camera.position.y ? player.getBody().getPosition().y: camera.position.y;
      camera.update();
      levelGenerator.generate(camera.position.y + camera.viewportHeight /2,camera.position.y - camera.viewportHeight /2);
      }
  
      //game ended
      if(player.getBody().getPosition().y&lt; camera.position.y - camera.viewportHeight/2 -player.HEIGHT/2 &amp;&amp; state == RUNNING){
          gameOverScreen.updateScore(score.getText().toString().substring(7));
          state = END;
      }
      if(state == END){
          gameOverScreen.setVisible(true);
      }
      //drawing game
      batch.setProjectionMatrix(camera.combined);
      batch.begin();
      renderBackground();
      renderPlatform();
      renderPlayer();
      Assets.sparks.draw(batch, delta);
      batch.end();
  }
  
  public void renderPlatform(){
      //world.getBodies(tmpBodies);
      //for(Body body : tmpBodies)
      //  if(body.getUserData() != null &amp;&amp; body.getUserData() instanceof Platform)
              for(int i=0;i&lt;platforms.size();i++){
  
              Body body = platforms.get(i).getBody();
              Sprite sprite = platforms.get(i).getSprite();
              sprite.setPosition(body.getPosition().x - sprite.getWidth()/2, body.getPosition().y - sprite.getHeight()/2);
              sprite.setRotation(body.getAngle() * MathUtils.radiansToDegrees);
              sprite.draw(batch);
          }
  }
  
  public void renderPlayer(){
      world.getBodies(tmpBodies);
      for(Body body : tmpBodies)
          if(body.getUserData() != null &amp;&amp; body.getUserData() instanceof Player){
              Player player = (Player) body.getUserData();
              Sprite sprite = player.getSprite();
              sprite.setPosition(body.getPosition().x - sprite.getWidth()/2, body.getPosition().y - sprite.getHeight()/2);
              //sprite.setRotation(body.getAngle() * MathUtils.radiansToDegrees);
              sprite.draw(batch);
              if(player.isPlayEffect()){
                  Assets.sparks.setPosition(body.getPosition().x , body.getPosition().y - sprite.getHeight()/2);
                  Assets.sparks.setDuration(200);
                  Assets.sparks.start();
              }
  
          }
  }
  
  public void renderBackground(){
      world.getBodies(tmpBodies);
      for(Body body : tmpBodies)
          if(body.getUserData() != null &amp;&amp; body.getUserData() instanceof Background){
              Background background = (Background) body.getUserData();
              Sprite sprite = background.getSprite();
              //sprite.setPosition(body.getPosition().x - sprite.getWidth()/2, body.getPosition().y - sprite.getHeight()/2);
              sprite.setBounds(bottomLeft.x, camera.position.y - camera.viewportHeight /2, camera.viewportWidth, camera.viewportHeight);
              sprite.draw(batch);
          }
  
  }
  private void doPhysicsStep(float deltaTime) {
      // fixed time step
      // max frame time to avoid spiral of death (on slow devices)
      float frameTime = Math.min(deltaTime, 0.05f);
      accumulator += frameTime;
      while (accumulator &gt;= TIMESTEP) {
          world.step(TIMESTEP, VELOCITYITERATIONS, POSITIONITERATIONS);
          accumulator -= TIMESTEP;
      }
  }
  </code></pre>
  
  <p>and player update:</p>
  
  <pre><code>public void update(float delta) {
      stateTime += delta;
      if(state==JUMP){
          sprite.setRegion(jump.getKeyFrame(stateTime));
          if(jump.isAnimationFinished(stateTime)){
              state = IDLE;
              stateTime = 0;
          }
      }else{
          sprite.setRegion(idle.getKeyFrame(stateTime));
      }
      if(Gdx.app.getType() == ApplicationType.Android )
          velocity.x = -Gdx.input.getAccelerometerX() * (movementForce / 10f);
      if(applyJump){
      body.applyLinearImpulse(0, jumpPower, body.getWorldCenter().x, body.getWorldCenter().y, true);
      applyJump = false;}
      body.setLinearVelocity(velocity.x, body.getLinearVelocity().y);
  }
  </code></pre>
  
  <p>where <code>applyJump</code> variable is setted at contact in <code>postSolve()</code> method.</p>
  
  <p>Thanks in advance</p>