Weird erratic pathing movement?

Im trying to fix the up and down erratic movements the pathing makes so it will be more smooth.

dzt67uGx50w


package net.gasquake.sentinel.entity;

import net.gasquake.framework.entity.Entity;
import net.gasquake.framework.resources.Screen;
import net.gasquake.framework.util.Tilemap;
import net.gasquake.sentinel.res.Textures;
import net.gasquake.sentinel.states.Play;

public class Enemy extends Entity {

	Tilemap tm;
	Player player;
	Textures tex;
	private boolean triggered = false;
	
	public Enemy(int x, int y, int w, int h, Tilemap tm, Textures tex, Player player) {
		super(x, y, w, h);
		this.tm = tm;
		this.player = player;
		this.tex = tex;
	}
	
	public void update() {
		triggered = false;
		if (player.getX() <= x) {
			dx = -2;
		}
		if (player.getX() >= x) {
			dx = 2;
		}		
		if (tm.tilemapCollision(this, Play.worldArray, w, h, 48, 0, 0)) {
			dy = -3;
			triggered = true;
		}
		if (triggered == false) {
			dy = 4;
		}
		tm.tilemapCollision(this, Play.worldArray, w, h, 48, 1);
		move(dx, dy);
	}
	
	public void render() {
		Screen.render(tex.playerRight, this);
	}
	
}

This doesnt have anything to do with the collision its just the pathing I think. :confused: Ideas?

Why do you think it doesn’t have anything to do with the collision?

When you detect a collision, you’re moving the sprite up 3 pixels. This is causing the jumpiness.

Instead of moving the sprite up, you should “snap” the bottom of the sprite to the top of the block.

You also might want to make sure that your code doesn’t treat collisions with a wall like a collision with the ground.