Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


NavMeshAgent

Navigation mesh agent.
Read time 8 minutesLast updated 6 days ago

Definition

[HelpURL("https://docs.unity3d.com/Packages/com.unity.ai.navigation@2.0/manual/NavMeshAgent.html")]public sealed class NavMeshAgent : Behaviour

Remarks

Attach this component to a mobile character in the game to allow the character to use the NavMesh to navigate the scene. For more details refer to AI Navigation.

Properties

Property

Description

accelerationThe maximum acceleration of an agent as it follows a path, given in units / sec^2.
agentTypeIDThe type ID for the agent.
angularSpeedMaximum turning speed in (deg/s) while following a path.
areaMaskSpecifies which NavMesh areas are passable. Changing
areaMask
will make the path stale (see _isPathStale).
autoBrakingShould the agent brake automatically to avoid overshooting the destination point?
autoRepathShould the agent attempt to acquire a new path if the existing path becomes invalid?
autoTraverseOffMeshLinkShould the agent move across OffMeshLinks automatically?
avoidancePriorityThe avoidance priority level.
baseOffsetThe relative vertical displacement of the owning GameObject.
currentOffMeshLinkDataThe current OffMeshLinkData.
desiredVelocityThe desired velocity of the agent including any potential contribution from avoidance.
destinationGets or attempts to set the destination of the agent in world-space units.
hasPathDoes the agent currently have a path? (Read Only)
heightThe height of the agent for purposes of passing under obstacles, etc.
isOnNavMeshIs the agent currently bound to the navmesh?
isOnOffMeshLinkIs the agent currently positioned on an OffMeshLink?
isPathStaleIs the current path stale. (Read Only)
isStoppedUse this property to set, or get, whether the NavMesh agent stops or continues its movement along the current path.
navMeshOwnerReturns the owning object of the NavMesh the agent is currently placed on.
nextOffMeshLinkDataThe next OffMeshLinkData on the current path.
nextPositionGets or sets the simulation position of the navmesh agent.
obstacleAvoidanceTypeThe level of quality of avoidance.
pathProperty to get and set the current path.
pathPendingIs a path in the process of being computed but not yet ready? (Read Only)
pathStatusThe status of the current path (complete, partial or invalid).
radiusThe avoidance radius for the agent.
remainingDistanceThe distance between the agent's position and the destination on the current path.
speedMaximum movement speed when following a path.
steeringTargetGet the current steering target along the path.
stoppingDistanceStop within this distance from the target position.
updatePositionGets or sets whether the transform position is synchronized with the simulated agent position. The default value is true.
updateRotationShould the agent update the transform orientation?
updateUpAxisAllows you to specify whether the agent should be aligned to the up-axis of the NavMesh or link that it is placed on.
velocityAccess the current velocity of the NavMeshAgent component, or set a velocity to control the agent manually.

Methods

Method

Description

ActivateCurrentOffMeshLinkEnables or disables the current off-mesh link.
CalculatePathCalculate a path to a specified point and store the resulting path.
CompleteOffMeshLinkCompletes the movement on the current OffMeshLink.
FindClosestEdgeLocate the closest NavMesh edge.
GetAreaCostGets the cost for path calculation when crossing area of a particular type.
MoveApply relative movement to current position.
RaycastTrace a straight path towards a target postion in the NavMesh without moving the agent.
ResetPathClears the current path.
SamplePathPositionSample a position along the current path.
SetAreaCostSets the cost for traversing over areas of the area type.
SetDestinationSets or updates the destination thus triggering the calculation for a new path.
SetPathAssign a new path to this agent.
WarpWarps agent to the provided position.

Inheritance

Inherited Members

Operators

Operator

Description

operator ==Compares two object references to see if they refer to the same object.
boolDetermines whether the object exists.
operator !=Compares if two objects refer to a different object.