Sometimes, we want a moving object to slow down or prevent an AI NavMeshAgent controlled character from passing through an area of our game. Or, perhaps we want something such as a door or drawbridge to sometimes permit travel, and not at other times. We can't "bake" these objects into the NavMesh at design time since we want to change them during runtime.
While computationally more expensive (that is, they slow down your game more than static, non-navigable objects), NavMesh Obstacles are components that can be added to GameObjects, and these components can be enabled and disabled like any other component.
A special property of NavMesh Obstacles is that they can be set to "carve out" areas of the NavMesh, causing NavMeshAgents to then recalculate routes that avoid these carved out parts of the mesh.
In this recipe, you'll create a player-controlled red Cube that you can move to obstruct an AI NavMeshAgent...