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.
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.
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.