Jumpy Movement [need help]

Hello Everyone, Recently i have been having trouble with smooth movement. i have tried multiple ways but i continuesly get jumpy movement. i’m not sure if it has something to do with my game loop or is it something to do with how i move my player. Down below is my gameLoop how i move my player and my Input class. i would love some help thanks alot :slight_smile:

public void run() {
		long lastTime = System.nanoTime();
		double nsPerTick = 1000000000.0 / 60.0;

		int ticks = 0;
		int frames = 0;

		long lastTimer = System.currentTimeMillis();
		double delta = 0;

		init();

		while (running) {
			long now = System.nanoTime();
			delta += (now - lastTime) / nsPerTick;
			lastTime = now;
			while (delta >= 1) {
				ticks++;
				tick();
				delta--;
			}

			try {
				Thread.sleep(16);
			} catch (InterruptedException e) {
				e.printStackTrace();
			}

			frames++;
			render();

			if (System.currentTimeMillis() - lastTimer >= 1000) {
				lastTimer += 1000;

				System.out.println("FPS " + frames + " TICKS " + ticks);

				ticks = 0;
				frames = 0;
			}
		}
	}

Player Movement:

public void tick(ArrayList<grassBlock> grass){
		x += velX;
		y += fallSpeed;
		
		if(Falling){
			fallSpeed += Gravity;
		}
		
		if(fallSpeed == 5){
			fallSpeed = 5;
		}
	}

Input class:

public class Input implements KeyListener {

	public Game game;

	public Input(Game game) {
		this.game = game;
	}

	public void keyPressed(KeyEvent e) {
		int key = e.getKeyCode();
		if (key == KeyEvent.VK_A) {
			game.getPlayer().setVelX(-4);
		}else if (key == KeyEvent.VK_D) {
			game.getPlayer().setVelX(4);
		}
	}

	public void keyReleased(KeyEvent e) {
		int key = e.getKeyCode();
		if (key == KeyEvent.VK_A) {
			game.getPlayer().setVelX(0);
		}else if (key == KeyEvent.VK_D) {
			game.getPlayer().setVelX(0);
		}
	}

	public void keyTyped(KeyEvent e) {
	}

}

Thanks for help

If you have more than the desired time between two ticks you are performing the

tick();

action twice.
This means if you have a delta of 1.00000001 you will do the action two times. This might lead to your jumps.
Try to use the delta in your player class to determine the distance he fall or walked.