Version: 2021.2
LanguageEnglish
  • C#

NavMesh

class in UnityEngine.AI

/

Implemented in:UnityEngine.AIModule

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Description

Singleton class to access the baked NavMesh.

Use the NavMesh class to perform spatial queries such as pathfinding and walkability tests. This class also lets you set the pathfinding cost for specific area types, and tweak the global behavior of pathfinding and avoidance.

Before you can use spatial queries, you must first bake the NavMesh to your scene.

See also:
Building a NavMesh – for more information on how to setup and bake NavMesh
Areas and Costs – to learn how to use different Area types.
NavMeshAgent – to learn how to control and move NavMesh Agents.
NavMeshObstacle – to learn how to control NavMesh Obstacles using scripting.
OffMeshLink – to learn how to control Off-Mesh Links using scripting.

Static Properties

AllAreasArea mask constant that includes all NavMesh areas.
avoidancePredictionTimeDescribes how far in the future the agents predict collisions for avoidance.
onPreUpdateSet a function to be called before the NavMesh is updated during the frame update execution.
pathfindingIterationsPerFrameThe maximum number of nodes processed for each frame during the asynchronous pathfinding process.

Static Methods

AddLinkAdds a link to the NavMesh. The link is described by the NavMeshLinkData struct.
AddNavMeshDataAdds the specified NavMeshData to the game.
CalculatePathCalculate a path between two points and store the resulting path.
CalculateTriangulationCalculates triangulation of the current navmesh.
CreateSettingsCreates and returns a new entry of NavMesh build settings available for runtime NavMesh building.
FindClosestEdgeLocate the closest NavMesh edge from a point on the NavMesh.
GetAreaCostGets the cost for path finding over geometry of the area type.
GetAreaFromNameReturns the area index for a named NavMesh area type.
GetSettingsByIDReturns an existing entry of NavMesh build settings.
GetSettingsByIndexReturns an existing entry of NavMesh build settings by its ordered index.
GetSettingsCountReturns the number of registered NavMesh build settings.
GetSettingsNameFromIDReturns the name associated with the NavMesh build settings matching the provided agent type ID.
RaycastTrace a line between two points on the NavMesh.
RemoveAllNavMeshDataRemoves all NavMesh surfaces and links from the game.
RemoveLinkRemoves a link from the NavMesh.
RemoveNavMeshDataRemoves the specified NavMeshDataInstance from the game, making it unavailable for agents and queries.
RemoveSettingsRemoves the build settings matching the agent type ID.
SamplePositionFinds the nearest point based on the NavMesh within a specified range.
SetAreaCostSets the cost for finding path over geometry of the area type on all agents.

Delegates

OnNavMeshPreUpdateA delegate which can be used to register callback methods to be invoked before the NavMesh system updates.
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961