# Movement looks funny If player takes up multiple tiles in tile-based game

So here is my problem:

Start = +++
+++
+++
End = ---
---
---

Player = ***
***
***

+++000000000000
+++000000000000
+++000000000000
000000000000000
000000000000000
000000000000000
000000000000---
000000000000---
000000000000---


I've made an A* path finding algorithm to tell it where to go, and it works!

+***00000000000
+***00000000000
+***00000000000
000000000000000
000000000000000
000000000000000
000000000000---
000000000000---

+++000000000000
+***00000000000
+***00000000000
0***00000000000
000000000000000
000000000000000
000000000000---
000000000000---
000000000000---
000000000000---

+++000000000000
++***0000000000
++***0000000000
00***0000000000
000000000000000
000000000000000
000000000000---
000000000000---
000000000000---

+++000000000000
+++000000000000
++***0000000000
00***0000000000
00***0000000000
000000000000000
000000000000---
000000000000---
000000000000---

+++000000000000
+++000000000000
+++***000000000
000***000000000
000***000000000
000000000000000
000000000000---
000000000000---
000000000000---

+++000000000000
+++000000000000
+++000000000000
000***000000000
000***000000000
000***000000000
000000000000---
000000000000---
000000000000---
etc...


The player also has 4 sprite sheet animations: looking up, looking left, looking right, and looking down. My problem is that, moving this way, the player jitters from looking right to down really quickly, making it look like it is spazzing, and ultimately it is aesthetically unappealing. In a game where the player takes up one tile, it looks OK, but if it takes up, say 3X3 or 4X4, it does not. I want to make it have a move diagonal animation as a last resort, so any tips are appreciated. Thank You!

One possible solution, without modifying the computation or directness of the path itself (which might have unwanted effects on your gameplay), is to just tweak your logic for selecting which animation or frame to display.

When the animation controller asks the movement logic which way it's moving, the movement logic can tell it a little white lie:

• If my current movement direction is different from the last one I reported, and my path takes me only one tile before I change direction again, then report back the last direction instead.

• Otherwise, report back the actual direction of movement

That should help smooth-out the small steps you'll have when walking along arbitrary diagonals - the avatar will just keep facing the dominant direction (for 45-degree angles, picking one arbitrarily based on the way it was facing at the start of the path)

If you find the zigzag step of the movement itself is also distracting, you can tell a similar lie about the display position of your character - interpolating over multiple moves - again without impacting the underlying tile-based movement logic.

• Likely the easiest solution to implement. Just takes a little bit of history keeping and I think it would look just fine. Apr 11, 2016 at 3:14

The A* algorithm contains a heuristic, meaning you can modify it to get a path that may not be optimal, but better suits your requirements (i.e. prefer orthogonal movement over diagonal movement). You'd modify your A* algorithm to make quick direction changes more costly. For example, if you've just changed from going down to going right, the cost of going down again would be much higher than the cost of continuing to go right (if such option exists). This additional cost would reduce over longer stretches of straight moves.

Alternatively, since you don't appear to be allowing diagonal movement, you get this jitter back and forth between orthogonal movements. One solution is to allow diagonal movements and simply choose the most appropriate orthogonal animation.