# AI movement in 2D

I've got a prototype of a game I've been mocking up and found myself struggling to find a solution for AI movement in a 2D tile based game. Here's the issue: The player is free to roam throughout the grid on floats. Enemies are to be able to move in the same manner. I've used simple a* pathfinding for the enemies to use but unfortunately I can't seem to think of a logical/tested solution for getting my enemies around the map in a fluid manner.

In this situation, how can I achieve fluid / not gridlocked movement?

## 1 Answer

I've had some trouble with this myself. I've never actually found a perfect way to do it, but a* pathfinding with Jump point search should make it possible. Take a look at this: http://gamedevelopment.tutsplus.com/tutorials/how-to-speed-up-a-pathfinding-with-the-jump-point-search-algorithm--gamedev-5818

• The pathfinding itself is great. Works perfectly. However this bounds my ai to moving only on these large tiles. I call my pathfinder, it returns a path as a list of points. My movement system propels the object according to it's speed/velocity until it gets near each point, then it targets the next point. The ai is unable to keep up with a player who is able to move unrestricted in the grid. I suppose that a smaller grid might do the trick. Divide each tile into 4 (8) different nodes for pathfinding? – user3926198 Jan 19 '15 at 16:29
• With normal a star pathfinding on a uniform grid, you' allways get 8 directions to go to. But with every tile you add to the path, you could check if you have a direct line of sight between the ai character and the tile. If you don't, add the previous tile to the list of waypoints. If you do, check the next one. This way, you could give the ai almost 360 degrees of freedom. – Peethor Jan 19 '15 at 20:22