Navigation Mesh
A navigation mesh is a navigation area which is arranged above the surface of the arbitrary mesh. In fact, the navigation mesh is the area of the specified height above the mesh polygons, which is available for pathfinding.
In contrast to navigation sectors, the navigation mesh enables the following:
- Only 2D routes can be calculated within the navigation mesh.
- Pathfinding can be performed within 1 navigation mesh only. Pathfinding within the following areas is not supported:
- Within several intersecting navigation meshes.
- Within the intersecting navigation mesh and sector.
See also
- The NavigationMesh class to edit navigation meshes via UnigineScript
- The article on Creating Routes to learn how to create routes inside the navigation mesh
- A set of samples located in the data/samples/paths folder:
- mesh_00
- route_03
- route_04
Creating Navigation Mesh
Before adding a navigation mesh, you should prepare a mesh, on which this navigation mesh will be based. Such mesh is created separately and should meet the following requirements:
- Any polygon of the mesh must not share its edge with more than 2 other polygons; otherwise, an error will occur.
- Mesh polygons should be as wide as possible (ideally, they should be equilateral). Too narrow and high polygons may reduce accuracy of path calculation.
- The mesh should be optimized: it should not contain a large number of polygons.
When a mesh is prepared, you can add the navigation mesh to the scene via UnigineEditor:
- Run UnigineEditor.
- On the Menu bar, click Create -> Path -> Navigation Mesh.
- In the file dialog window that opens, choose the required mesh to be used as a base for the new navigation area and click Ok.
- Click somewhere in the world to place the navigation mesh. The new navigation mesh will be added to UnigineEditor and you will be able to edit it via the Nodes panel.
Example
If you have a scene with different objects and you need to calculate a 2D route among them, you will need to add the navigation mesh to this scene as follows:
- Create a flat mesh with holes in places where the objects are positioned.
The sceneThe mesh created for the navigation mesh
- Specify this mesh as a base for a navigation mesh within which the route will be calculated and add the navigation mesh to the world. It will be highlighted in green:
A navigation mesh based on the flat mesh
- Place the navigation mesh above the scene.
The navigation mesh positioned above the scene
Editing Navigation Mesh
On the Navigation tab of the Nodes panel, you can adjust the following parameters of the navigation mesh:
Loading a New Mesh
To load a new mesh on which the navigation area will be based:
- On the Navigation tab, press .
- In the file dialog window that opens, choose the required mesh and press Ok.
Saving the Current Mesh
To save the current mesh on which the navigation area is based:
- On the Navigation tab, press .
- In the file dialog window that opens, specify a name for the mesh and press Ok.