Now, we will learn how to make the proper changes to the NavMesh settings before baking:
- Create the game world with different areas. In our case, we will have regular areas (walkable), doors, and swamps.
- Open the Navigation window: Menu | Window | Navigation.
- Go to the Areas tab.
- Create a Swamp area with cost 6.
- Create a Door area with cost 2.
- Select the objects that will behave like swamps.
- Go to the Navigation window, and select the Objects tab.
- Change the Navigation Area value to Swamp.
- Select the objects that will behave like doors.
- Go to the Navigation window, and select the Objects tab.
- Change the Navigation Area value to Door.
- Bake the NavMesh:
Resulting baked NavMesh
Then, we need to set up the agents so they behave as intended with the designated areas:
- Add the agent object to the scene.
- Add the NavMesh component to the object.
- Go to the Inspector window.
- Select the available areas that the agent can traverse. In our case, deselect the Door area mask:
NavMeshAgent configuration for enemies that cannot walk through doors