PathEngine home previous: Controlsnext: 'LotsOfAgentsAndHardCollision'
Contents, Programmers Guide, Example Projects, Other Examples, 'SeparatingGroups', Description of Approach

Description of Approach

As mentioned previously, we start with a situation where agents can cross through each other freely, and then add in two main avoidance components:

Managing at-rest agents

The first priority is really to avoid agents coming to rest and standing in positions that overlap other agents, but we then also ensure that once agents are at rest they are treated more generally as pathfinding obstacles, and avoided by other pathing agents.

The key point is essentially just to track when agents start and stop moving, and maintain a separate collision context that contains only those agents which are currently at rest.
This collision context is then used by other agents for resolving target positions (with the findClosestUnobstructedPosition() functionality), for pathfind requests and for collision checks during movement along the resulting paths.

Queueing interactions

Apart from when coming to rest, the most common situation where agents will tend to overlap one another is within groups that share the same movement order.
In this specific situation we can avoid more complicated velocity resolution techniques and apply much simpler 'queueing' interactions, based on local proximity tests.

The approach taken in this case is very simple in that it only operates on agent speed, and doesn't affect movement direction.
We detect when group agents are within a specified distance threshold (implemented through the definition of a larger 'avoidance shape', and collision tests at the agent's position using this shape), and reduce agent speed in a way that is designed to separate the agent's concerned.

To decide which agent should be slowed down, we define a kind of priority ordering based on remaining path length to the current group target.
So, when two agents within a group get too close, the agent further from the target gets slowed down.

Documentation for PathEngine release 6.03 - Copyright © 2002-2021 PathEnginenext: 'LotsOfAgentsAndHardCollision'