Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


NavWorld

Provides access to the navigation mesh world and performs navigation query operations.
Read time 4 minutesLast updated 19 days ago

Definition

public struct NavWorld : IDisposable, IEquatable<NavWorld>

Remarks

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.

Methods

Method

Description

AddDependencyTells the NavMesh world to halt any changes until the specified job is completed.
BeginFindPathInitiates a pathfinding operation between two locations on the NavMesh.
ContinueFindPathContinues a path search that is in progress.
CreateLocationConstructs a valid NavLocation from a position and a navigation node.
DisposeReleases this NavWorld handle and prevents any further operations on it.
EndFindPathObtains the number of nodes in the path computed by a successful NavWorld.ContinueFindPath operation.
EqualsDetermines whether two NavWorld handles refer to the same underlying NavMesh world.
GetAgentTypeIdForNodeObtains the identifier of the agent type that the NavMesh surface or link containing the specified node is built for.
GetAreaIndexForNodeObtains the area type index assigned to the specified NavMesh node.
GetEdgesAndNeighborsRetrieves the vertices of a specified node and the identifiers of all the navigation nodes to which it connects.
GetGeneratedLinkNodesRetrieves the NavNode identifiers for internal navigation links baked into the specified NavMeshDataInstance.
GetGeneratedLinksCountObtains the total number of internal navigation links baked into the specified NavMeshDataInstance.
GetHashCodeCalculates the hash code for use in collections.
GetInstanceTransformRetrieves the position and rotation of the NavMesh surface that contains the specified NavMesh node.
GetLinkNodeRetrieves the navigation node of a link that connects to one or more NavMeshes.
GetNodeTypeDetermines whether the NavMesh node is a polygon or a link.
GetPortalPointsObtains the end points of the line segment common to two adjacent NavMesh nodes.
GetResultFromFindPathCopies the NavMesh nodes that form the path found by the NavWorld operation into the provided array.
IsValidChecks whether the NavWorld has been properly initialized.
MapLocationFinds the closest point and NavNode on the NavMesh for a given world position.
MoveLocationTranslates a NavMesh location to another position without losing contact with the surface.
MoveLocationsTranslates a series of NavMesh locations to other positions without losing contact with the surface, given one common area filter for all of them.
RaycastTraces a line between two points on the NavMesh.

Static Methods

Method

Description

GetDefaultWorldObtains a reference to the navigation mesh world where all navigation operations occur.

Operators

Operator

Description

operator ==Checks whether two NavWorld values refer to the same underlying NavMesh world.
operator !=Checks whether two NavWorld values refer to different underlying NavMesh worlds.