Pathfinding
Pathfinding is how agents move around the scene. The tool has built-in support for three pathfinding solutions, and a documented route for adding your own.
Setting the pathfinding solution
Open BardTreeLtd/Civil AI/Module Settings and find the Nav Agent section. Changing the Nav Mode option runs a check that the right packages are installed, and prevents the change if they are not, with a warning in the Console.
There are four Nav Mode values: NONE, UNITY, ASTAR and AGENT_NAVIGATION. UNITY is the default.
Adding the package
Download and install the package you wish to use and add it to the project.
You then need to add that package to the CIVIL-AI-SYSTEM Assembly Definition Asset, which is at the root of the tool (Assets/BardTreeLtd/CIVIL-AI-SYSTEM). Add it under Assembly Definition References. Which file you reference depends on the package, and sometimes on its version, since packages occasionally rename or restructure their assemblies.
Options
Unity
The out-of-the-box implementation, and the default. Nothing to install beyond the AI Navigation package (com.unity.ai.navigation).
Add a NavMeshSurface to your scene, set Collect Objects to All, and bake. Your ground needs a collider or the bake produces nothing.
A* Pathfinding Project
A popular and long standing pathfinding solution in the Unity community is supported.
Specific files to Assembly Definition (V5^)
- AstarPathfindingProject
- PackageTools
- ALINE
Agents Navigation
Another popular package which provides good performance benefits over the unity base version
Specific files to Assembly Definition (V4^)
- ProjectDawn.Navigation
Adding your Own
The tool is designed to be expandable, so you can add your own solution in four steps. This shouldn't cause too many conflicts on version changes.
- Create your own implementation of the interface
INavMeshAgent. - Add the new name to the
NAV_MODEenum. - Update the
LoadNavMeshAgentfunction inSettingsLoaderto create your new class. - Set the Nav Mode.
Next step
If agents spawn but never move, navigation is the first thing to check — see Common Issues.