We can create objects whose meshes are defined as more expensive for NavMeshAgents to travel across, helping AI agent behavior be more realistic in terms of choosing faster paths that avoid water, mud, and so on.
To create a custom NavMesh Area (we'll pretend it's mud) with a higher traveling cost, do the following:
- In the Navigation window, reveal the areas by clicking the Areas button. Then, define a new area named Mud with a cost of 2:
Figure 10.11 – Defining Mud as a NavMesh area
- Create a new 3D Cylinder named Cylinder-mud positioned at (0, -4.9, 0) and scaled to (5,5,5).
- Ensure that the Cylinder-mud GameObject is selected in the Hierarchy window and that the Navigation window is displayed.
- In the Navigation window, click the Object button, check Navigation Static, and choose Mud from the Navigation Area drop-down list:
Figure...