Working with Unity’s Nav Mesh System for Smart AI

Christian Carter
3 min readOct 27, 2021

--

In the last tutorial it covered creating a point and click movement system using Unity’s Nav Mesh System. You can find that tutorial here. This is a review of how to setup a Nav Mesh AI. First you need to open the Navigation window. That can be found in the Window->AI menu dropdown.

This example uses a plane for the floor, a capsule for the player, and cubes for obstacles. For movement, this will use the point and click movement from the previous tutorial. Make sure you give your player the component Nav Mesh Agent. This will allow your player to navigate the area you have created.

With the Navigation window open you can see it has 4 sub areas: Agents, Areas, Bake, and Object. Agents will give attributes to the player, enemies or anything else that will use the Nav Mesh for navigation. Areas are how you define different objects and how the Nav Mesh will interact with them. This tutorial will only use Walkable and Not Walkable. Bake is where you update the Nav Mesh by Baking it. Object is where you can set what type of Area an Object is.

As you add objects that will be part of the Nav Mesh you need to set them to static and then set if they are Walkable or Not Walkable. Then make sure you bake your Navigation again. You will see that it updates the blue Nav Mesh area around the new cube so that you will not run into it as you move about.

If you have an object that is walkable and it is below the step height when you update the Nav Mesh it will now turn blue so you can move onto it.

These are the basics of adding objects and incorporating them into your Nav Mesh. You can start building terrain using this method and have a moveable environment.

-Chris

--

--