6

I'm working on a game that uses A-star (A*) for path finding but I've come to a point where by I have some objects that are larger than a single grid square.

I'm running on a grid of 16*16px. wall segments are 16*16 and so make a single square impassable. Some of my baddies are 32*32 and so they need to check that a gap is at least 2 grid square wide in order to be able to pass throguh it.

I can't simply make the grid 32*32 as the design requires thin walls (at 16px) and there are a couple of smaller baddies that only take up a single 16*16 square.

How do I implement this mutli-resolution environment? Is A-star still the correct tool to use?

Greg B
  • 14,597
  • 18
  • 87
  • 141

1 Answers1

1

For a relatively simple solution, I would stick to the same A* algorithm as for 16x16 sized objects but with a slightly different way to evaluate if a square is walkable or not.

  • A 16x16 sized object can walk on a square if that square is walkable.
  • A 32x32 sized object can walk on a square if that square and its' neighbors are all walkable.
Martin G
  • 17,357
  • 9
  • 82
  • 98
  • 1
    Unfortunately, this won't work when a gap is 2 squares tall. Both squares of the gap have non-walkable neighbours so report as non-walkable. It might be better to say a tile is walkable for 32-sized objects if the square below it, to its right, and below-and-right are also walkable. – Matthew Gatland Jun 29 '15 at 07:27