E
Enako_Inc
Guest
Hello, apologies if this is in the wrong place but I'm having a problem with the code I'm using to have enemies face the player character. Basically whats happening is if the enemy and the player character are sharing the same x position (e.g. directly above or below the player) the enemy sprite will endlessly flip its xscale. Here is my code:
GML:
//face player
if (instance_exists(obj_player))
{
var x_to_player = x - obj_player.x;
if (x_to_player != 0)
{
image_xscale = -1 * sign(x_to_player);
}
}