A* Pathfinding Project  4.1.12
The A* Pathfinding Project for Unity 3D
Multiple agent types

This page explains how to handle different agent types, such as agents of different sizes.

When you have agents of different sizes they usually cannot take the same routes to the target. Fortunately it is easy to solve this problem. The easiest way is to create multiple graphs, one for each type of agent. If you have a lot of different agent types, or perhaps even a continous spectrum, you may want to group them as having a large number of graphs will increase memory usage and scanning will take longer. On the Seeker component it is possible to set which graphs that the Seeker can use.

See also
Seeker.graphMask
NNConstraint.graphMask

As an alternative method on grid graphs it is possible to make the graph generate different tags depending on the distance to the nearest obstacle.

See also
Pathfinding.GridGraph.erosionUseTags

Example

Lets say we have these two agents:

In the AstarPath inspector we can then create 2 different graphs, with the only difference being the character radius that is used (any other parameters can of course be changed if necessary). In this example a recast graph has been used, but this can just as easily be done with another graph type.

When scanning these graphs we will get a result that looks something like this. With the graph for the smaller agent in blue and the graph for the larger agent in purple.

On the Seeker component we can then set which graph each agent should use:

Now both agents will use graphs appropriate for their size: