Pathfinding + Formation

I’m currently working on a prototype for a mobile RTS. I have a good idea how I’m going to handle the pathfinding for it, using an on-the-fly version of A*. However, I have absolutely no idea where to start for formations. Since it’s a mobile game, I really don’t want any collision detection beyond pathfinding, but I definitely don’t want units to all blob up whenever they move.

Any good ideas on this?

Look into BOIDS.
There should be some open source code for it with examples for Unity lying around.

Perhaps you could modify that? I don’t know how well it would support formations though (as in, neat pretty formations).

http://www.unifycommunity.com/wiki/index.php?title=Flocking
Try that

Model your formations as a group of offsets from a central pivot. Assign the resulting positions as the starting node for each character in the group, then pathfinding proceeds normally.

Hmmm… let me try to describe exactly what I want:

  1. I want to calculate a group of unit’s path as one (they’ll, ideally, never be seperated, so this should be OK)
  2. I want them to travel in something resembling a formation; a blob is OK
  3. With minimal collision detection, I’d like the units on the outer edge of the blob/formation to not clip with obstacles.

I am not sure if I did it the hard way or not but works really well. I just did something like(I have square, triangle, and free form formations) -
Triangle Formation

  • How many units
  • Starting with 1 row with one unit
  • Each row after has one extra unit.
  • Once its determined how many rows we will have assign each unit a position in the row and offset the position from whatever point you want, some people do it by the center, I did mine based on the unit in position number 1 in row 1.

On the square formation I just had a equation that took total number of units * .3 and thats how many units would be in each row. Then went from there and figured out based on the unit count how many columns were needed to be setup based on only have 30% of the units in each row. If that makes sense.

The 30% can be adjusted of course but that 30% reminded me of how the formations worked in Red Alert.