The introduction of Unity's NavMeshAgent has greatly simplified the coding for NPC (Non-Player Character) and enemy agent behaviors. In this recipe, we'll add some wall obstacles (scaled cubes), and generate a NavMesh so that Unity knows not to try to walk through walls. We'll then add a NavMeshAgent component to our NPC GameObject, and tell it to head to a stated destination location by intelligently planning and following a path, while avoiding the wall obstacles.
When the Navigation panel is visible, then the Scene panel displays the blue-shaded walkable areas, as well as unshaded, non-walkable areas at the edge of the terrain and around each of the two wall objects:
![](https://static.packt-cdn.com/products/9781788471909/graphics/assets/048040cc-d5f7-4f63-a674-d305ba4c62e6.png)