Joining several NavMeshes with a single NavMeshSurface
We have a single NavMeshSurface component in our terrain. However, what a NavMeshSurface does is look for navigable meshes in the scene with a similar orientation – that means close to horizontal for the orientation of the GameObject that has a NavMeshSurface component. In this recipe, we’ll first add a large cube to the scene, and then rebake the NavMesh to see how the top of the cube gets its own NavMesh. We’ll then tilt the cube (a little) to see how NavMeshes can join up if the gap and slope between them are not too great:
Figure 12.17: Joined NavMeshes allowing travel up the slope
Getting ready
This recipe adds to the first recipe in this chapter, so make a copy of that project folder and do your work for this recipe with that copy.
How to do it...
To work with non-horizontal NavMeshes, follow these steps:
- Add a new 3D cube to the scene, named
Cube-slope
. Scale this...