Unity Navigation pathfinding

Navigation objects are used to calculate pathfinding routes for Characters to take. Even if you are not making a Point and Click game, pathfinding is still used by NPCs to navigate a scene.

Unity Navigation-based pathfinding lets you build a mesh inside the scene view, and bake it using Unity's own Navigation tool. The alternative method is to use a custom Mesh Collider, which is more flexible but requires custom 3D modelling in a separate application. That method is described in the next tutorial.

To make your scene rely on Unity Navigation for pathfinding, choose Unity Navigation from the "Scene settings" field in the Settings Manager:

The available prefab buttons in the "Create new object" panel alter based on your settings - when you select Unity Navigation as your pathfinding method, NavMeshSegment becomes available.

Click to create a new segment. NavMeshSegments are rather like flat CollisionCubes, and you must arrange them in your scene to mark out the "walkable area". You may need to create and stretch several out to cover the entire floor, but it's fine for them to overlap.

Note that you don't have to use these prefabs - you can still bake your own Navigation meshes if you prefer. However, to be able to point and click a character around the scene, the floor colliders must be placed on the NavMesh layer - this is why it can often be easier to make use of NavMeshSegements.

When you have finished, open Unity's Navigation window from the top toolbar, under Window -> Navigation.

The segments will be used in tamden with the NavMesh we're about to bake, because they'll be detecting our mouse clicks, so we want the NavMesh's boundaries to stick closely to the segments. Underneath the Navigation window's Bake tab, reduce the Radius and Height settings to their lowest values.

Then click Bake, and a transparent green area should cover your segments. This is your baked NavMesh.

If the Bake has failed, or the baked NavMesh looks wrong, make sure that the only GameObjects in your scene marked with "Navigation Static" the flag are your segments. You can see a GameObject's static flags to the right of it's name in the Inspector:

Adventure Creator and this website are copyright Chris Burton, ICEBOX Studios

Go to top