User Tools
Sidebar
Using RAIN
AI Characters
Environment
rainelements:navmeshrig
Table of Contents
Navigation Mesh Rig
Properties
- Size: The size of the Navigation Mesh along one side. This is used along with scale to define the region that will be included in the mesh.
- Automatic Grid Size (Advanced): If checked, the Navigation Mesh will automatically determine the Grid Size of the mesh based on its overall cell resolution.
- Grid Size (Advanced): The maximum number of times the Navigation Mesh will be split on a side when generating. This is useful for speeding up large meshes as each grid square can be calculated on a separate thread.
- Mesh Color: The color of the Navigation Mesh visualization after it is generated.
- Display Mode: The current visualization that the Navigation Mesh is showing.
- None: Don't display any visualization.
- GridLines: Show where the grid squares of the mesh will be when it is generated.
- ColliderMesh: Show what colliders will be included, and whether or not it is walkable (after previewed or generated).
- NavigationMesh: Show what the Navigation Mesh looks like (after generated).
- Included Layers: Any colliders within these layers will be included in the mesh.
- Ignored Tags: Any colliders with one of these tags will be excluded from generation.
- Unwalkable Tags: Any colliders with one of these tags will be marked completely unwalkable.
- Graph Tags (Advanced): Used in conjunction with the Graph Tags located on the Basic Navigator. They can be used to limit what graphs are available to a specific AI.
- Max Slope: The maximum slope to consider walkable on a collider.
- Walkable Height: The amount of clearance necessary to consider an area walkable.
- Walkable Radius: The distance from a wall or unwalkable area before an area is walkable.
- Step Height: How high up to consider when connecting two adjacent areas.
- Cell Size: The resolution of the Navigation Mesh in meters. The higher this value the more accurate the mesh is at small sizes, but the more memory and time it will take to generate. The resolution of your mesh can be calculates by the following equation: size * localScale.x * cellSize * size * localScale.z * cellSize.
- Max Vertex Error (Advanced): When smoothing the edges of the Navigation Mesh, this is the maximum distance a vertex can be from the smooth line after removing.
Actions
- Generate Navigation Mesh: Generate the Navigation Mesh using the current properties. Also generates all of the visuals that go along with the mesh.
Usage
Code
One use of accessing the Navigation Mesh Rig in code is to generate a Navigation Mesh outside of the editor.
using RAIN.Navigation.NavMesh; using System.Threading; using UnityEngine; public class NavmeshGenerator : MonoBehaviour { [SerializeField] private bool _test = false; [SerializeField] private int _threadCount = 4; // This is just to test the runtime generation public void Update() { if (_test) { GenerateNavmesh(); _test = false; } } // This will regenerate the navigation mesh when called public void GenerateNavmesh() { NavMeshRig tRig = GetComponent<NavMeshRig>(); // Unregister any navigation mesh we may already have (probably none if you are using this) tRig.NavMesh.UnregisterNavigationGraph(); tRig.NavMesh.StartCreatingContours(tRig, _threadCount); while (tRig.NavMesh.Creating) { tRig.NavMesh.CreateContours(); // This could be changed to a yield (and the function to a coroutine) although as // of RAIN of 2.1.4.0 (fixed since then), our navigation mesh editor has issues with it Thread.Sleep(10); } tRig.NavMesh.RegisterNavigationGraph(); } }
See Also
rainelements/navmeshrig.txt · Last modified: 2022/02/23 13:00 by sigil
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Noncommercial-Share Alike 3.0 Unported