15
\$\begingroup\$

I managed to get pathfinding work for a single unit, and I managed to avoid agent-agent collision, but now I need to be able to send a group of agents to some location.

This is my set-up so far:

  • Waypoint pathfinding
  • The minimum distance between two nodes is a little bigger than the biggest bounding sphere radius allowed for an agent.
  • Agents avoid collisions with other agents by doing some steering behaviour I based on clearpath

So now I need to send my agents somewhere in group. I have read some posts saying that some way to do it is to create a group leader and give the other units offsets to his position.

But then the problem is, what if the group formation cannot be achieved? e.g. you want to form a rectangle, but at the target position there is a structure nearby which prevents you from creating a rectangle setup.

\$\endgroup\$
2
  • 2
    \$\begingroup\$ I´m at work so I don´t have time to write up a proper answer, but here are my zero point two cents: Use a Boids flocking algorithm and then represent obstacles as objects that the Boids are repulsed from. \$\endgroup\$
    – Nailer
    Commented Apr 27, 2012 at 14:06
  • \$\begingroup\$ @Nailer he flocking algorithm would work as long as they are moving , but then how would I detect if their final position is "okay", and notify them that they can stop moving? Don't worry, I can wait for your answer ;) \$\endgroup\$
    – xcrypt
    Commented Apr 27, 2012 at 14:35

2 Answers 2

14
\$\begingroup\$

There is actually a pretty nice article about this over at Gamasutra. And covers topics like formations and resolving collisions:

enter image description here

And another article from them on the same topic, which is a bit shorter but has more pseudo code examples:

enter image description here

Finally, a nifty thing to think about when implementing your system is the idea of a "Flow Field" Supreme Commander 2 used this; And it's based on Washington State University's Crowd Flows research.

\$\endgroup\$
1
  • \$\begingroup\$ Thanks, I have seen the continuum crowds pathfinding stuff from supreme commander, but I think I'll stick with what I have atm. I'll try that when I get a bit more exp, because yeah it looks really nifty ;D \$\endgroup\$
    – xcrypt
    Commented Apr 27, 2012 at 16:43
2
\$\begingroup\$

I think you can have a invisible "flock entity" that is the boss of the formation, and make so the other creatures position himself relative to this entity. If this entity can rotate, then the relative position will rotate too.

...oopos.. you are already doing that.

What about this:

Why you cant calculate new positions for the entities colliding? I don't need to be fancy, maybe just dram a line from the desired original point, and the leader, and move the desired position to the middle of this line. Test again for collision.

\$\endgroup\$
3
  • \$\begingroup\$ Well that's pretty much what I said in my question :D The tricky part is how to handle the collision of the formation with the terrain/obstacles/structures \$\endgroup\$
    – xcrypt
    Commented Apr 27, 2012 at 12:40
  • \$\begingroup\$ Sorry!, I have updated my reply with a new idea. \$\endgroup\$
    – Tei
    Commented Apr 27, 2012 at 12:45
  • \$\begingroup\$ I don't get it, you would just halve the magnitude of the offset vector and keep checking if this is a collision free position? That would most likely fail in many cases \$\endgroup\$
    – xcrypt
    Commented Apr 27, 2012 at 12:58

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .