This page will walk you through the steps of setting up basic pathfinding in an existing scene.
- Add a NavSurface component to a Gameobject.
All colliders that should be considered for pathfinding need to be children of the NavSurface component.
- On the NavSurface component click on the button labeled "Bake".
You should see an outline appear indicating which edges are walkable.
- Optional: Place NavLinks to connect parts of the walkable outline.
Make sure to place the start and end point of NavLinks close to the outline. If a point is to far from the outline, it will not be able to mapped at play time and the corresponding NavLink won't work.
- Add a NavAgent component to your NPC's.
In order for the NavAgent to know where it is, it must be placed close to the outline, like the NavLink points.
- Give the NavAgent somewhere to go to.
The easiest way to do this is to attach a RandomWalker component. It will cause the NavAgent to try and reach a random point on the walkable contour.
I highly recommend checking out the example scenes to see different setups in action.