So i´m trying to let the enemy follow the hero when he´s in range of him.
But i don´t have a clue on how to do this.
Can somebody help me.
Enemy name = Gnomus
Hero name = Garp
Gnomus Follows garp in certrain range.
public void act()
{
Garp garp = getObjectsInRange(range, Garp.class).get(0);
if (garp != null) {
turnTowards(garp.getX(), garp.getY());
move(movespeed);
}
}
Garp garp = getObjectsInRange(range, Garp.class).get(0);
public void act()
{
List garpList = getObjectsInRange(range, Garp.class);
if (!garpList.isEmpty()) {
Garp garp = (Garp)garpList.get(0);
if (garp != null) {
turnTowards(garp.getX(), garp.getY());
move(movespeed);
}
}
}