Connecting multiple instances of NavMesh
We have learned how to build a NavMesh, but there are cases where levels are really complex to the point of needing to divide them in several sections; sometimes, this is because there are pitfalls or because we are loading our level programmatically.
Getting ready
It is important to work on top of objects that have at least one NavMeshSurface
component attached.
How to do it...
We need to connect one NavMeshSurface
component to another one:
- Locate, via the editor or code, two
NavMeshSurface
components to connect - Add the
NavMeshLink
component to the object that will work as the origin - Select the agent type that will be able to use the connection
- Set the
Start Point
andEnd Point
values - Repeat the previous steps for every agent type for which you need to connect the nodes
How it works...
Imagine one NavMeshSurface
component working as a big node in a graph. By using the NavMeshLink
component, we add an edge between two nodes. It's worth noting that the coordinates...