Is there a way to calculate the cost of a path on a 8 point grid *as if* it were a 4 point?

Hello! Simply put, I’m making a tactics game, and using ConstantPath.Construct() to find all nodes within reach. I want my characters to make diagonal movements. However, I want the cost of a diagonal movement to be 2 (or 20000 gcost), not 1.4. I suppose I could have 2 identical grids, 1 for movement and 1 for calculating valid nodes, with the calculating grid being a 4 point connection and the movement one being an 8 point, but that seems messy and I’m worried it might introduce bugs if I accidentally plug in the wrong grid while coding. I’d rather have it contained to the script in charge of finding a valid path.

This shows the results I’m getting with some advanced editing techniques (MSpaint) to mark the parts of the grid I don’t want to be available

Hi

It looks like you might be able to use the PathUtilities.BFS method: https://arongranberg.com/astar/docs/pathutilities.html#BFS

Thanks for the reply Aaron! I’m afraid that I feel like I’m missing something, as I’m getting the exact same result.

Am I supposed to use a bitmask? I’m not sure where to begin there, I see the bitmask explanation in the documentation, but I have no idea how to actually utilize it to create a result. This is the code I’m using, the commented out code is the previous method, at 139-146 I’m referencing some custom code which only grabs nodes in the correct distance, but has no way to check for walkability or cost, which solves some issues but still leaves the problem where the player can move farther than intended around obstacles. Checknodes used to be assigned to that value, I just swapped it into this pathfinder.bfs calculation to test

Ah, I misread your original post. I thought you meant a cost of 1 for diagonals instead of 1.4. But you said 2.

I suppose you could copy-paste the BFS code from the package (it’s quite short) into your own script and make some modifications to it to only use the straight connections and ignore the diagonal ones.
I don’t think there’s a way to do what you want out of the box on an 8-connected graph.