How to do it...

Now, we will learn how to make the proper changes to the NavMesh settings before baking:

  1. Create the game world with different areas. In our case, we will have regular areas (walkable), doors, and swamps.
  2. Open the Navigation window: Menu | Window | Navigation.
  3. Go to the Areas tab.
  4. Create a Swamp area with cost 6.
  5. Create a Door area with cost 2.
  6. Select the objects that will behave like swamps.
  7. Go to the Navigation window, and select the Objects tab.
  8. Change the Navigation Area value to Swamp.
  9. Select the objects that will behave like doors.
  10. Go to the Navigation window, and select the Objects tab.
  11. Change the Navigation Area value to Door.
  1. Bake the NavMesh:
Resulting baked NavMesh

Then, we need to set up the agents so they behave as intended with the designated areas:

  1. Add the agent object to the scene.
  2. Add the NavMesh component to the object.
  3. Go to the Inspector window.
  4. 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
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.227.52