WEBVTT

00:02.650 --> 00:08.560
In this lecture, I'll introduce you to a powerful concept using AI navigation called navigation measures

00:08.560 --> 00:10.030
or NAV measures.

00:10.390 --> 00:16.720
NAV measures are a built in unity feature and are used to divide an environment up into navigable areas

00:16.720 --> 00:20.800
which the star algorithm can then be used on for pathfinding.

00:20.830 --> 00:27.280
The method, originally called a Meadow Map, was developed for robotic applications in the mid 1980s.

00:27.310 --> 00:34.150
It became more popular in the 2000s for use in games and nav mesh divides a model into a series of polygons

00:34.150 --> 00:36.010
and assigns a cost to each.

00:36.130 --> 00:41.770
This cost is considered in the pathfinding algorithm in determining the best path for an AI to take.

00:42.220 --> 00:45.460
We call the AI using a nav mesh and agent.

00:45.460 --> 00:52.660
This is a generic term originating in traditional AI, where words like NPC agent and bot all mean the

00:52.660 --> 00:53.560
same thing.

00:53.890 --> 01:00.880
There are four tabs in the unity navigation system for setting up a nav mesh agent areas, bike and

01:00.880 --> 01:01.630
object.

01:01.780 --> 01:03.690
The first defines an agent.

01:03.700 --> 01:09.530
An agent has four main properties that you can set to define the character's size and movement abilities.

01:09.550 --> 01:14.530
These are used by nav mesh to determine where a character can and can't go in the environment.

01:14.560 --> 01:20.140
Note They are not based on the properties you might set in the physics system, nor are they based on

01:20.140 --> 01:22.110
the model size you're using.

01:22.120 --> 01:23.890
So set these carefully.

01:23.920 --> 01:28.850
The size of an agent is defined by a cylinder that the character would fit within.

01:28.870 --> 01:35.020
It has a radius for determining how wide your character is, and a height is generally assumed.

01:35.020 --> 01:37.960
The character will be navigating across a flat terrain.

01:37.960 --> 01:44.020
But in the case of slopes and steps, you need to declare the gradient of slopes accessible by the character

01:44.020 --> 01:47.170
as well as the height of stairs that it can access.

01:47.560 --> 01:52.840
The Agents tab will also let you define different sized agents by adding more than one type.

01:53.140 --> 01:58.570
This allows you to have many types of agents, all with differing sizes and navigation abilities.

01:58.600 --> 02:03.460
The Areas tab is where you can define different costs for differing parts of the NAV mesh.

02:03.490 --> 02:09.520
The cost is used by the star algorithm to calculate the best path across the mesh from one location

02:09.520 --> 02:10.360
to another.

02:10.390 --> 02:16.420
There are three built in types that are used to set different parts of a mesh to walkable, not walkable,

02:16.420 --> 02:17.440
and jump a ball.

02:17.470 --> 02:19.330
To these, you can add your own.

02:19.570 --> 02:25.870
Any area type can be included or excluded in an agent's pathfinding search across the terrain.

02:25.900 --> 02:31.060
This makes it possible to have some characters unable to traverse water or walk through doorways.

02:31.090 --> 02:34.030
The bag tab turns your meshes into a nav mesh.

02:34.060 --> 02:39.220
It does this by dividing the mesh into numerous polygons and determines where the agent should be able

02:39.220 --> 02:42.060
to travel using the baked agent's size.

02:42.070 --> 02:47.950
When you create a nav mesh in the bike tab, it uses this agent size and not the sizes you set up in

02:47.950 --> 02:49.270
the agents tab.

02:49.720 --> 02:55.390
By default, the humanoid agent type is the only agent type recognised by the nav mesh.

02:55.540 --> 03:01.660
And even though you can define multiple agent types in the agent tab, you can only use humanoid in

03:01.660 --> 03:03.790
the set up given to you via unity.

03:03.820 --> 03:09.130
Having said that, there are beta components available that will allow you to set up different NAV measures

03:09.130 --> 03:10.480
for different agent types.

03:10.480 --> 03:13.090
And we will look at this in later workshops.

03:13.120 --> 03:16.990
Other basic settings include being able to generate off mesh links.

03:17.020 --> 03:21.550
These define how far across a gap in the mesh an agent can fall or jump.

03:21.550 --> 03:25.690
The detail of the nav mesh can be set using the manual voxel setting.

03:25.900 --> 03:31.000
Voxels are a data structure used to divide the world up before the nav mesh is constructed.

03:31.090 --> 03:36.430
The bigger the voxel size, the less accurate the native mesh, as bigger world divisions will miss

03:36.430 --> 03:38.320
some of the detail in the mesh.

03:38.950 --> 03:42.610
This value is usually set to three per agent radius.

03:42.610 --> 03:45.940
You are aiming for values around two and four.

03:45.970 --> 03:51.250
The minimum region area allows you to remove sections of the mesh that were calculated as navigable

03:51.250 --> 03:53.260
but are too small to be of any use.

03:53.260 --> 03:56.230
And you don't really want them included in the pathfinding.

03:56.230 --> 04:01.390
By increasing the minimum region, area and re baking, you can remove these small areas.

04:01.390 --> 04:06.340
When enough mesh is generated for a bunch of measures, it averages out the height and can do things

04:06.340 --> 04:08.610
like turning stairs into a slope.

04:08.620 --> 04:14.100
If this is not the effect you're are after, then you can turn on the height mesh box before baking.

04:14.110 --> 04:16.940
This will include height values into the mesh.

04:16.960 --> 04:19.960
It will also take up more memory and baking time.

04:19.960 --> 04:22.140
So don't be too generous with its use.

04:22.150 --> 04:23.100
The last tab.

04:23.110 --> 04:28.150
The object tab is where you can align specific area types to different parts of your mesh.

04:28.390 --> 04:31.360
These are the areas defined in the areas tab.

04:31.750 --> 04:38.140
This tab also allows you to specify which parts of your scene you want to create a mesh for, as well

04:38.140 --> 04:43.570
as generating off mesh links that allow you to transition from one nav mesh to another.

04:43.600 --> 04:49.180
NAV meshes are a powerful system to get your NPCs moving with very little effort on your behalf.

04:49.480 --> 04:54.880
With them, you can create all types of scenarios from patrols and crowds to traffic and flocks.

04:55.270 --> 05:00.580
In this section, we will examine some of the fundamental elements that make NAV measures work and create

05:00.580 --> 05:01.860
some examples that really.

05:02.190 --> 05:03.450
Straight their power.
