the code that is here is for the enemy to follow the player the only problem is that the enemy starts to rotate in a way that i dont want it to, does anyone know of a way to follow the player without changing the enemies rotation
//to attack player if he´s somewhere around the enemy
public void atackPlayer()
{
if(!getObjectsInRange(200, Player.class).isEmpty())
{
Actor player = (Actor) getObjectsInRange(200, Player.class).get(0);
if(player != null)
{
followPlayer();
}
}
}
//this is the code for the enemy to follow the player
public void followPlayer()
{
turnTowards(Player.xPlayer , Player.yPlayer); /*this is the problem over here, is there any other way of figuring out the players position without comprimising the rotation of the enemy*/
move(1);
Actor player = (Actor) getOneIntersectingObject(Player.class);
if(player != null)
{
getWorld().removeObject(player);
}
}
thanks to anyone that responds

