Unity Navigation Example with Camera Controls

We have a structure with a “Nav Mesh”, “Nav Mesh Agent” and mouse click to set the destination.   To make the demo more interesting,  I added a “Nav Mesh Obstacle” component to the gate and control script to a flattened cube that will serve as the gate switch that toggles the gate up or down when clicked.

We’re in 3D these days and not limited to the Zaxxon view (or the isometric view for developers after the 8-bit era) so I’ll setup a 3D camera view control to enable rotating/orbiting around the structure.

The “Nav Mesh Obstacle” can also be setup with the “Carve” property enabled which will carve/cut out the Nav Mesh when the obstacle is present so the agent will not attempt to follow the path blocked by the designated object.  I used a door/gate as an example of a temporary obstacle so the Carve is not enabled, and the Agent will assume the path can be cleared.  Mythbuster’s final season Zombie volunteer special had a nice example of blocking a path with a “Carve” property on out-of-commission Zombies so the remaining horde had to Pathfind an alternate route to get to Adam’s weapon of choice.

For questions, comments or contact – Twitter @rlozada