**solved**
I am making an actor called "Stalker" that just slowly moves closer and closer to the player, damaging on contact. It is working mostly okay, but is teleporting randomly. Not to random locations however; it teleports itself to the X or Y coordinate of the player (a perfect line vertical or sideways from the player) then continues moving as normal from there, until teleporting again.
This is the code for the stalker
I've been trying to figure out why it only teleports every like 6 seconds, not just every single act() cycle. Once I know that, I think I can make it stop teleporting. Any help appreciated :D!
public class Stalker extends GroundMover { Room room; Stats stats; Character character; double moveSpeed = 1; double yMomentum, xMomentum = 0; public void addedToWorld(World world) { room = (Room)getWorld(); stats = room.stats; character = room.character; } public void act() { findPlayerAndMove(); detectCollision((int)moveSpeed, (int)xMomentum, (int)yMomentum); //this is a method in the superclass (what this is a subclass of). No problems with it } public void findPlayerAndMove() { xMomentum = (character.getX() - getX()); yMomentum = (character.getY() - getY()); //determine which direction to move if(Math.abs(xMomentum) > Math.abs(yMomentum)) { yMomentum = 0; } else if(Math.abs(yMomentum) > Math.abs(xMomentum)) { xMomentum = 0; } if(yMomentum > moveSpeed) { yMomentum = moveSpeed; } if(xMomentum > moveSpeed) { xMomentum = moveSpeed; } setLocation(((int)(getX() + xMomentum)), ((int)(getY() + yMomentum))); } }