Per-agent obstacles in the graph?

Consider a map which has dynamic obstacles, such as a locked door. Now say that there are multiple agens, some of which “see” the locked door, and others which are far away and haven’t observed it.

How should I approach this that each agent has their own modifications to the graph based on some external logic? (such as based on what they walk nearby).

Does this mean I need a graph per agent? Or is there some other way to make sure the agent will first navigate in a path “through” the locked door, until it gets close enough for some external mechanism to trigger an update?

Or maybe there is a possibility to just add a per-agent penalty to certain nodes?


Per agent obstacles can be added using the ITraversalProvider. See the bottom of this page:
At the moment it is not possible to specify a traversal provider for the built-in movement scripts, but you can take control over the path calculations yourself like this:

// Prevent the agent from calculating its own paths
ai.canSearch = false;
// Start calculating a path to the agent's destination and assign it a traversal provider
var p = ABPath.Construct(ai.position, ai.destination);
p.traversalProvider = myCustomTraveralProvider;
1 Like