Easiest group movment
I'm sure there are other/better ways of doing it, but here are a couple techniques I've seen and/or attempted.
I assume your game is an rts, or something similar...
1. When moving a group of units, put them all into a Group, and assign a Leader. Find the path for the Leader, then have all the other units follow their Leader. I implemented a simple 'Move in formation' technique, where all followers try to stay at a certain position relative to their leader. Doing this allows for a 3x3, 4x4, 1,2,3 pyramid, etc formations. If a follower hits an obstruction, get around it, and either have them play catch up, or tell the group to wait for that unit to get back in position.
Things to take into consideration are how to handle things like bottle necks, or an obstruction that splits the group.
In some situations the formation may not be viable, and a single file line would be needed...
2. I haven't tried this method, but it seems like a logical way to do it. Put the units into a Group, and determine the size of that group (height and width). Make an abstract Rectangle from these dimensions, and modify your pathfinding algo to take this rectangle and find a path for it. Like I said I haven't tried this, so not sure if its a viable way.
Not sure if this is helpful, or close to what you need, but it might give you a few ideas.
Geo
The way I did it, only the leader makes path requests. Every time the leader reaches a waypoint in the path, he assigns new waypoints to the followers. So each follower only knows his immediate waypoint. He moves directly towards it without requesting a path. Only if he is blocked, does he request a path. I don't have collisions between entities, which simplifies things.
The assigned waypoints are the relative formation positions, rotated by the leader's heading. If there is no room at the spot where a waypoint should have been, you can assign the closest one via a limited A* search from the leader's waypoint. "AI Wisdom 4" explains all this.
In my implementation, there is some relatively complicated messaging logic going on to get the group to wait for stragglers and so on. I have had plenty of deadlock bugs to iron out, where the group members were waiting for each other.
Dave Mark - President and Lead Designer of Intrinsic Algorithm LLC
Professional consultant on game AI, mathematical modeling, simulation modeling
Co-founder and 10 year advisor of the GDC AI Summit
Author of the book, Behavioral Mathematics for Game AI
Blogs I write:
IA News - What's happening at IA | IA on AI - AI news and notes | Post-Play'em - Observations on AI of games I play
"Reducing the world to mathematical equations!"
I'll implement that Option 1.
But i want to have group collision, so the followers follow the leader and if they collide with a movable object, they just wait and try to follow their waypoint later?
Thank you
broom
Dave Mark - President and Lead Designer of Intrinsic Algorithm LLC
Professional consultant on game AI, mathematical modeling, simulation modeling
Co-founder and 10 year advisor of the GDC AI Summit
Author of the book, Behavioral Mathematics for Game AI
Blogs I write:
IA News - What's happening at IA | IA on AI - AI news and notes | Post-Play'em - Observations on AI of games I play
"Reducing the world to mathematical equations!"
It's pretty cool because your groups always stay together, they can avoid dynamic obstacles along the way (each group is effectively a single "unit" with a deformable shape). The solution does require more work than the simple method presented earlier in this thread (you need to create a roadmap and a system for local planning) but it appears pretty robust.
Anyway, I'm probably doing a poor job describing it. Read the paper for yourself.
The thing done in a group is really effecting. The group can do many things which the alone person can't even think of.
Joe
(assuming you dont have dynamic scenery that might invalidate the path for the followers).
Each object follows the path were they are spaced out (maybe tiny pathfind to get them 'into line'.. to 'fall in' to the initial line ordering) all movement is at the same rate so there would be no collisions.
If the line isnt too long (object count low) it can look reasonable but funny if too long (conga line).
On roads its very natural.
Variations would be two/thre/many abreast. Depending on your terrain system and object sizing scheme you may have to do the 'fit between things' processing anyway and the formation would just be a fixed width spacing.