1
\$\begingroup\$

By editing my A* algorithm as such that:

  • a tile is valid if all of its neighbours are valid (checking this N-1 deep)

I can find N wide paths, where N is odd, and my unit just follow the "center" tiles.

But what if my unit is even tiles wide?

Yes, I generate a 2 tiles wide path, and then traverse it with an offset, so my unit will walk on the overlapping edge between the 2 tiles. (maybe there is a better solution, suggestions are welcome)

But how do I find even wide paths?

(Or my whole approach is bad?)

\$\endgroup\$
1
\$\begingroup\$

instead of pathfinding on the centers of the tiles, pathfind along the corners and edges of the tiles.

A corner is valid if all the neighbouring tiles are valid according to your existing algorithm(n-1)

\$\endgroup\$
0
\$\begingroup\$

Draw an NxN square with the tile in the corner. The tile is only valid if every tile in the square is valid.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.