I just want the spider to move left for X seconds, then right for the same amount of time, on a loop. My code instantly stops the spider from moving
public class Spider extends Actor
{
public int patrolDelay;
public boolean goingLeft;
public void act()
{
patrolArea();
patrolDelay--;
}
public void patrolArea()
{
if(getObjectsInRange(200, PlayerOne.class).isEmpty())
{
if (goingLeft && patrolDelay < 1)
{
move(3);
goingLeft = false;
patrolDelay = 300;
}
if (!goingLeft && patrolDelay < 1)
{
move(-3);
goingLeft = true;
patrolDelay = 300;
}
}
}
