In this lecture, I'll introduce you to a powerful concept using AI navigation called navigation measures
or NAV measures.
NAV measures are a built in unity feature and are used to divide an environment up into navigable areas
which the star algorithm can then be used on for pathfinding.
The method, originally called a Meadow Map, was developed for robotic applications in the mid 1980s.
It became more popular in the 2000s for use in games and nav mesh divides a model into a series of polygons
and assigns a cost to each.
This cost is considered in the pathfinding algorithm in determining the best path for an AI to take.
We call the AI using a nav mesh and agent.
This is a generic term originating in traditional AI, where words like NPC agent and bot all mean the
same thing.
There are four tabs in the unity navigation system for setting up a nav mesh agent areas, bike and
object.
The first defines an agent.
An agent has four main properties that you can set to define the character's size and movement abilities.
These are used by nav mesh to determine where a character can and can't go in the environment.
Note They are not based on the properties you might set in the physics system, nor are they based on
the model size you're using.
So set these carefully.
The size of an agent is defined by a cylinder that the character would fit within.
It has a radius for determining how wide your character is, and a height is generally assumed.
The character will be navigating across a flat terrain.
But in the case of slopes and steps, you need to declare the gradient of slopes accessible by the character
as well as the height of stairs that it can access.
The Agents tab will also let you define different sized agents by adding more than one type.
This allows you to have many types of agents, all with differing sizes and navigation abilities.
The Areas tab is where you can define different costs for differing parts of the NAV mesh.
The cost is used by the star algorithm to calculate the best path across the mesh from one location
to another.
There are three built in types that are used to set different parts of a mesh to walkable, not walkable,
and jump a ball.
To these, you can add your own.
Any area type can be included or excluded in an agent's pathfinding search across the terrain.
This makes it possible to have some characters unable to traverse water or walk through doorways.
The bag tab turns your meshes into a nav mesh.
It does this by dividing the mesh into numerous polygons and determines where the agent should be able
to travel using the baked agent's size.
When you create a nav mesh in the bike tab, it uses this agent size and not the sizes you set up in
the agents tab.
By default, the humanoid agent type is the only agent type recognised by the nav mesh.
And even though you can define multiple agent types in the agent tab, you can only use humanoid in
the set up given to you via unity.
Having said that, there are beta components available that will allow you to set up different NAV measures
for different agent types.
And we will look at this in later workshops.
Other basic settings include being able to generate off mesh links.
These define how far across a gap in the mesh an agent can fall or jump.
The detail of the nav mesh can be set using the manual voxel setting.
Voxels are a data structure used to divide the world up before the nav mesh is constructed.
The bigger the voxel size, the less accurate the native mesh, as bigger world divisions will miss
some of the detail in the mesh.
This value is usually set to three per agent radius.
You are aiming for values around two and four.
The minimum region area allows you to remove sections of the mesh that were calculated as navigable
but are too small to be of any use.
And you don't really want them included in the pathfinding.
By increasing the minimum region, area and re baking, you can remove these small areas.
When enough mesh is generated for a bunch of measures, it averages out the height and can do things
like turning stairs into a slope.
If this is not the effect you're are after, then you can turn on the height mesh box before baking.
This will include height values into the mesh.
It will also take up more memory and baking time.
So don't be too generous with its use.
The last tab.
The object tab is where you can align specific area types to different parts of your mesh.
These are the areas defined in the areas tab.
This tab also allows you to specify which parts of your scene you want to create a mesh for, as well
as generating off mesh links that allow you to transition from one nav mesh to another.
NAV meshes are a powerful system to get your NPCs moving with very little effort on your behalf.
With them, you can create all types of scenarios from patrols and crowds to traffic and flocks.
In this section, we will examine some of the fundamental elements that make NAV measures work and create
some examples that really.
Straight their power.