Game Development Reference
In-Depth Information
Note
Another setting in the scene that can cause problems is the
Tun-
nelSoundTrigger
Sound Toggler script. As it isn't important to use, select the
TunneISoundTrigger
script and remove that component to avoid errors later.
Using Unity's built-in NavMesh system
The next thing we need for our car demo is a navigation mesh. Smart Car uses Un-
ity's built-in system. Unity's system is similar to RAIN's but we haven't used it much
yet as unlike other plugins, Unity does not have a built-in behavior tree system. For-
tunately, we don't need behavior trees for our car demos, so navigate to
Window
|
Navigation
.
This brings up the
Navigation
tab with three subtabs to help configure the NavMesh:
•
Object
: This helps you filter what objects in the scene are part of the nav-
igation mesh. Any objects that are tagged with
Navigation Static
will be in-
cluded in the mesh as a walkable area.
•
Bake
: This has options to bake the mesh. The two most important options
are
Radius
and
Height
, which are dimensions for the character to navigate
on the mesh.
•
Layers
: This allows you to customize the placement of different navigation
meshes on different layers.
For our demo, we want only the roads to be navigable. Select the other building and
miscellaneous objects in the scene and set their static property (which is to the right
of their name in
Inspector
) to not have
Navigation Static
set. Then, for the differ-
ent road objects, such as
Road_Coll
,
Road_Coll01
, and so on, make sure that they
have
Navigation Static
checked. Then, go back to the
Navigation
tab and click on
Bake
. If you have everything set correctly after you bake, you should see the navig-
ation mesh in the same area as the road: