Starting an NPC agent
Now, let's create an AI agent for the level, something that can interact with the player. First, the agent needs a physical mesh representation in the scene. For this, I used the Constructor
mesh, which is part of the Unity Character Controllers package imported earlier. Drag-and-drop this from the Project panel into the scene and then remove any animator component that might be created, as shown in the following screenshot. The animations will be important, but a custom-made animator controller will be created later.
Tip
Remember that we're not using the third-person controller prefab; it's just the constructor mesh alone.
Next, add a NavMeshAgent
component to the object by navigating to Component | Navigation | Nav Mesh Agent. This allows the object to work with the navigation mesh, and it is able to find and travel paths when instructed. Set both the Radius and Height values of the component to match the dimensions of...