This section talks about the pathfinding system. This is not a tutorial. Pathfinding is automatically taken care of for you, so you don’t have to do anything about it. Our A.I. uses the default Unity NavMesh agent pathfinding system. We chose this because it comes with Unity out-of-the-box without you having to install 3rd party pathfinding tools. We tried to make our system work as much as possible with this to make it easier for you. If you want to suggest a 3rd party pathfinding system, send us an email and, depending on demand, we may add it in the future.
So continue reading if you want to learn more about the pathfinding system or if you want to edit it yourself. For 95% of use cases, you don’t need to read this section.
Like weapon systems, there many different Pathfinding solutions out there that we cannot predict which one you will use.
So we went with the default Pathfinding method used by the Unity Engine itself: NavMesh Pathfinding. This allows you to hit the ground running without having to purchase or download 3rd party pathfinding libraries.
This A.I. framework is powered by NavMeshes. You will need to bake your scene’s Navigation Mesh each time you change the environment, or the bots will not function properly.
We designed the bot’s movement system to be able to support other Pathfinding systems, in case you do not wish to use Unity’s NavMesh solution (although that is really all you need in most cases).
CALCULATING A PATH: In the Movement FSM, there are States named “Calculate Path”. Here, you enter whichever API or action your Pathfinding system uses to calculate a path from the bot’s current position, to “currentMoveToLocV3” (vector3 variable).
After the path is calculated, you must use your Pathfinding system’s command for moving along that path.
Your pathfinding system should use the following variable for its destination. All of them are located in the MOVEMENT FSM.
currentMoveToLocV3 – A vector3 variable used for Chasing, MoveTO commands, and Random Nearby Patrol commands.
If you are using waypoints, you must retrieve the waypoint node, and store the node’s world position inside currentMoveToLocV3 before telling the Pathfinding system to calculate a path. Depending on the system you are using, you might need to first get the position of your bot as a Vector3. This should be done for you and stored in the variable, “myPosition” in the MOVEMENT FSM.
Depending on demand, we might implement other pathfinding solutions in a future update, such as Aron’s A* pathfinding project. However, we must balance the framework in terms of ease-of-customization and complex bloated features.