Looking at that code, it seems like the enemy can only move if the x move direction is non-zero. Is that what you really want? It doesn’t look like it covers the case of the enemy moving straight up or down (x is zero, y is non-zero). Maybe the first check should use >= instead of >, for example.
Secondly, in the (x > 0) block, you will always either play the Right or Up animation. Skull_down will never play.
For this logic to work better, it probably would look something like this:
if (y > 0.5)
anim.Play("Skull_Up");
else if (y < -0.5)
anim.Play("Skull_Down");
else if (x > 0)
anim.Play("Skull_Right");
else if (x < 0)
anim.Play("Skull_Left");
else
anim.Play("Idle);
(I just threw that Idle check in there, you decide if you need it or not
)
However, if the target is perfectly diagonal to the enemy, then you might run into jittering if you use 0.5. I suppose this is the problem you were trying to describe in your first post? If so, then I think I understand what you’re asking now.
If this is a tile based game, then one easy answer is to use 0.45 instead of 0.5 (or 0.55 or whatever). However, if it’s a tile-based game, why use this logic? Just go with positive, negative, or zero checks.
If it’s not a tile-based game and you really do need 360 degree movement, then I’d add a timer so that the animation will only change if enough time has passed (like half of a second or something so you don’t keep flipping every frame).
As you mentioned you were making an old school Zelda game, I originally took that to mean you were creating a tile based game, where you can only move in one of 8 directions.
Finally, you’ll want to cache Control.movedirection.normalized instead of re-calculating it every time you need it.