A* Pathfinding Project

Point graph on 2D Isometric tile map


#1

Hello. Sorry for my poor English, but I have a problem with current plugin. I use a Point graph on my two 2D tile maps and one of them is 2D Isometric map. I found that A* gives me a strange path and even in some scenarios a long path on my 2D isometric map. There are some examples of A* results between 2D Isometric map and simple 2D map “Top view”:




Different result with length:



As you can see, something wrong with point nodes when it placed in “isometric style”.
Of course I’ve tried to use Isometric Grid graph. But, I have walls between my cells on the map and I don’t think that I can use Grid graph for multiple floors unlike Point Graph.

So, what can I do in current situation? I need your advice. Thank you.


#2

Well, I guess I found a solution: #costMagnitude

var cost = (uint)(node2.position - node1.position).costMagnitude;

It works:


#3

Hi

So if you make a point graph with the shape of an isometric graph, the problem is that the point graph has no idea that you don’t actually want to use the real world distances between the nodes as the costs. The grid graph’s isometric option will handle this automatically for you and make the costs between the nodes be correct. If you want to prevent the extra connections it might be better (i.e. faster pathfinding and less memory usage) to post process the grid graph instead to remove the node connections that you do not want. Something like

AstarPath.active.data.gridGraph.GetNodes(node => ... loop through the node connections and remove the ones you do not want)