Manhattan Distance between tiles in a hexagonal grid

前端 未结 6 933
北海茫月
北海茫月 2020-12-08 07:57

For a square grid the euclidean distance between tile A and B is:

distance = sqrt(sqr(x1-x2)) + sqr(y1-y2))

For an actor constrained to mo

6条回答
  •  北荒
    北荒 (楼主)
    2020-12-08 08:42

    If you define the different hexagons as a graph, you can get the shortest path from node A to node B. Since the distance from the hexagon centers is constant, set that as the edge weight.

    This will probably be inefficient for large fields though.

提交回复
热议问题