Search code examples
c#xnaphysicspath-findinggame-physics

Using A* and still avoiding collisions?


I am designing a tower-defense game, and for that I am using the A* pathfinding algorithm to reach my destination from my spawn-areas.

The problem here is that all the units stack, which doesn't look visually good. Is there a way I can make them somehow group instead, and spread more if there's not enough space?

The algorithm works so that all units move a single tile at a time.


Solution

  • You can use flock behavior to have them follow the same general path but not stack up on each other. There is an XNA example provided by MS here: http://xbox.create.msdn.com/en-US/education/catalog/sample/flocking