Game Development Reference
In-Depth Information
Remember that we're not using the third-person controller prefab; it's just
the constructor mesh alone.
Next, add a
NavMeshAgent
component to the object by navigating to
Component
|
Navigation
|
Nav Mesh Agent
. This allows the object to work with the navigation
mesh, and it is able to find and travel paths when instructed. Set both the
Radius
and
Height
values of the component to match the dimensions of the mesh. Set the
Stopping Distance
to
2
; this controls how close to a destination that the player
should reach before stopping, as shown in the following screenshot. Of course, for
your own projects, the
Stopping Distance
value will probably need to be edited.
Configuring a NavMeshAgent component for pathfinding
Now, add a
Rigidbody
component and enable the
Is Kinematic
checkbox, as shown
in the following screenshot. This allows the object to enter trigger volumes and be a
part of the physics system by both causing and receiving physics events. However,
with
Is Kinematic
checked, Unity will not override the object's transformation
(position, rotation, and scale). This allows the
NavMeshAgent
exclusively to control
the movement of the character.
Configuring a Rigidbody component for physics