Turn Based Movement Points and Heuristics not working

I am experimenting with using A* pathfinding project in a turn based game. for the time being ive decided to do some preliminary testing using the built in turn based scripts.

one problem i have run into is the heuristics appear to not change anything about the penalty or cost of moving to specific nodes. For example, i’d like to set up a standard diagonal manhattan heuristic using 8 directional and be able to move 1 adjacent square including diagonals for 1 point.

however changing the heuristic does not seem to affect anything. since there is no openly direct way of changing the penalty cost of squares im not sure how to solve this problem. i’ve tried swapping between 4 and 8 directional, i’ve tried all the various options of heuristics. ive tried different graph types.

i think somewhere in TurnBasedManager script might be overriding something, but i’m not 100% sure.

Does anyone have any insight on how i could solve this issue? Thank you.


The heuristic is not supposed to change the cost of moving on the graph. The only purpose of different heuristics is to make the pathfinder choose between different paths with the same length. Take a look at this comparison: https://arongranberg.com/astar/docs/pathfinding.html#Heuristic

The standard grid graph uses the world-space distance as a cost between the nodes (though converted to integers by multiplying by 1000). So if you have a node size of 1 then the cost of moving to an adjacent node will be 1000, and moving along a diagonal is 1414. It is not possible by default to make diagonals have the same cost as non-diagonals. Though you can make a small change to the GridGenerator.cs script -> SetUpOffsetsAndCosts method to make it so.