Provides access to the navigation mesh world and performs navigation query operations.
The navigation mesh world assembles together a collection of NavMesh surfaces and links that are used as a whole for performing navigation operations. NavWorld operations can be executed inside jobs (IJob, IJobFor), as opposed to the operations in the NavMesh-related structures.
Operations are initialized against one world, can use only the NavMeshes inside that world and aren't aware of the existence of any other NavWorld.
Copying this object produces only a new reference to the same NavMesh data. It doesn't duplicate the data in memory. Use NavWorld.Equals or the == operator to determine whether two NavWorld handles refer to the same navigation data.
Every call to NavWorld.GetDefaultWorld produces a handle that you must release with NavWorld.Dispose when you stop using it. Obtain the handle once and keep it for as long as you run queries, rather than requesting a new one on every frame.
To obtain a path between two locations on the NavMesh, first create a NavQueryBuffer with a maxNodesToVisit value in the range from 1 to 65,535, then call the following NavWorld methods in this order: BeginFindPath, ContinueFindPath, EndFindPath, GetResultFromFindPath. You can call ContinueFindPath repeatedly. These methods store their intermediate state within the NavQueryBuffer. Other methods can be called in any order since they don't change state data.
All methods throw exceptions if any of their parameters aren't valid when executed in the Editor.
NavWorld.IsValid checks a NavWorld, a NavNode, or a NavLocation, so you can call it beforehand when their validity isn't already guaranteed. It doesn't cover every argument that a method validates, such as the size of an array or the agent type behind a location. These checks are optional: skip them when the surrounding code already produces valid arguments and you don't want to pay for the verification on every call.
Important: You can use only a single NavMesh world. Obtain a reference to it through the NavWorld.GetDefaultWorld method.
| Method | Description |
|---|---|
| AddDependency | Tells the NavMesh world to halt any changes until the specified job is completed. |
| BeginFindPath | Initiates a pathfinding operation between two locations on the NavMesh. |
| ContinueFindPath | Continues a path search that is in progress. |
| CreateLocation | Constructs a valid NavLocation from a position and a navigation node. |
| Dispose | Releases this NavWorld handle and prevents any further operations on it. |
| EndFindPath | Obtains the number of nodes in the path computed by a successful NavWorld.ContinueFindPath operation. |
| Equals | Determines whether two NavWorld handles refer to the same underlying NavMesh world. |
| GetAgentTypeIdForNode | Obtains the identifier of the agent type that the NavMesh surface or link containing the specified node is built for. |
| GetAreaIndexForNode | Obtains the area type index assigned to the specified NavMesh node. |
| GetEdgesAndNeighbors | Retrieves the vertices of a specified node and the identifiers of all the navigation nodes to which it connects. |
| GetGeneratedLinkNodes | Retrieves the NavNode identifiers for internal navigation links baked into the specified NavMeshDataInstance. |
| GetGeneratedLinksCount | Obtains the total number of internal navigation links baked into the specified NavMeshDataInstance. |
| GetHashCode | Calculates the hash code for use in collections. |
| GetInstanceTransform | Retrieves the position and rotation of the NavMesh surface that contains the specified NavMesh node. |
| GetLinkNode | Retrieves the navigation node of a link that connects to one or more NavMeshes. |
| GetNodeType | Determines whether the NavMesh node is a polygon or a link. |
| GetPortalPoints | Obtains the end points of the line segment common to two adjacent NavMesh nodes. |
| GetResultFromFindPath | Copies the NavMesh nodes that form the path found by the NavWorld operation into the provided array. |
| IsValid | Checks whether the NavWorld has been properly initialized. |
| MapLocation | Finds the closest point and NavNode on the NavMesh for a given world position. |
| MoveLocation | Translates a NavMesh location to another position without losing contact with the surface. |
| MoveLocations | Translates a series of NavMesh locations to other positions without losing contact with the surface. |
| Raycast | Traces a line between two points on the NavMesh. |
| Method | Description |
|---|---|
| GetDefaultWorld | Obtains a reference to the navigation mesh world where all navigation operations occur. |
| Operator | Description |
|---|---|
| operator != | Checks whether two NavWorld values refer to different underlying NavMesh worlds. |
| operator == | Checks whether two NavWorld values refer to the same underlying NavMesh world. |