Thursday, July 24, 2014

People sometimes ask about pathfinding on isometric grids. This is the wrong way to look at it.

You're finding paths in the game world. Isometric is not part of the game world. Isometric is how you look at the game world. Consider the shortest path from New York to San Francisco. Does the shortest path depend on how you hold the map? No! The person looking at the map does not matter. The shortest path is the same no matter how you are looking at the map.

Here's an animation showing the way to think about isometric grids. Note that the map coordinates and the path don't change; it's only the way we look at it that changes.

0,0 0,14 14,14 14,0

Pathfinding runs on the game map. The game map coordinates shouldn't depend on "top down" or "isometric".

Labels: ,


Wouter Lievens wrote at July 25, 2014 12:19 AM

Thanks for putting that so succinctly. I was really confused when I saw the post title in my rss readers, for the same reason as you state here.

I've noticed a more generic pattern in this, too. Many people start out building games by focusing entirely on the visualization, whereas I think you should go with the conventional software development practice of building a solid model first, and representing it appropriately later.

Love the animation, too.

Amit wrote at July 25, 2014 12:07 PM

Hi Wouter, thanks for the comment! I was beginning to wonder if I was the insane one. ;-)

I was very pleased with the animation and also the implementation. It's done in css, with only one line of javascript to trigger it. So simple!

Yes, it does seem that many people start with the graphics instead of the model and game logic. I'm seeing a similar confusion about camera, view, world coordinates, and I should post something about that too.