How to work with objects of different sizes in a path search situation (A *, A-star)

I am working on a game using the A-star (A *) to search for paths, but I have come to the conclusion that I have some objects that are larger than one square of the grid.

I am running on a 16 * 16px grid. wall segments 16 * 16 and therefore make one square impassable. Some of my villains are 32 * 32, and so they need to check that the gap is at least 2 squares of the grid in order to be able to go through it.

I can't just create a 32 * 32 grid, because the design requires thin walls (16 pixels), and there are several smaller villains that occupy only one 16 * 16 square.

How to implement this mutual resolution environment? Is A Star Still the Right Tool?

+5
source share
2 answers

For a relatively simple solution, I followed the same A * algorithm as for 16x16 objects, but in a slightly different way to evaluate whether the square is available or not.

  • An 16x16 object can walk a square if that square can be moved.
  • An object of size 32x32 can move around a square if that square and its neighbors are accessible.
0
source

All Articles