[2D][Isometric][Astar] Move diagonally except when there are two diagonal tiles blocked.

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Ignacio Freire

Hi guys,

First time posting here so if something is out of place please let me know so I can fix the post.

To my question, I have been stuck here for quite a bit and have posponed it but it’s time to do it.

I have an isometric 2D 37x37 tilemap and am using Astar to get all the tiles and obstacles. Keep in mind this is for a kind of tower defense game where you can build on the whole map to create a maze so the map gets updated every round.

Right now the cells only get connected to their sides (top, right, bottom, left) but not diagonally.

The current path is this:

Current Path

Whis is almost ok but I wanted the mobs to walk diagonally so I also added the connection with the diagonal tiles but unfortunately it wasn’t as I expected. It turned into the following:


When I want to get the path like this one:


So I was wondering if there is an easier way than checking each adjacent (including diagonally) tile for an obstacle before connecting all the cells as I think it’s quite underperforming.

Thank you!