NavMeshAgent— attaches to an NPC or entity and navigates to targets.NavMeshArea— marks a volume in the scene as blocked or as a custom area type.NavMeshLink— creates an off-mesh connection between two points, enabling jumps, ladders, or teleports.
The NavMesh itself is baked per-scene. Place
NavMeshArea and NavMeshLink components before baking, or mark them as dynamic so changes are applied at runtime.NavMeshAgent
NavMeshAgent navigates an entity across the scene’s NavMesh. Attach it to a GameObject and call MoveTo to start pathfinding. The agent integrates into the crowd system and avoids other agents automatically.
Physical properties
The height of the agent’s collision cylinder. Should match the character’s
CharacterController height.The radius of the agent’s collision cylinder. Should match the character’s
CharacterController radius.Movement properties
Maximum movement speed in world units per second.
Maximum rate of velocity change in world units per second squared. Set this equal to or higher than
MaxSpeed for snappy, responsive movement.When
true, the component writes the agent’s NavMesh position back to the GameObject’s world position each frame. Set to false to take manual control of positioning using AgentPosition.When
true, the GameObject automatically faces the direction of travel. Turn this off if you handle rotation yourself.Constraints
The set of area types the agent is permitted to traverse. If empty, all areas are allowed.
The set of area types the agent is not permitted to traverse. If empty, no areas are forbidden.
Whether the agent can travel on the default (untyped) NavMesh area.
When
true, the agent traverses NavMeshLink connections automatically. Set to false to handle link traversal yourself using CompleteLinkTraversal().How strongly the agent avoids other agents in the crowd. Range 0–1.
State
The agent’s current velocity as reported by the crowd simulation.
The velocity the agent wants to move at this frame. Pass this into a
CharacterController to combine navigation with physics-based movement.true when the agent has a valid path target and is actively moving toward it.The agent’s position on the NavMesh. Updated even when
UpdatePosition is false.The current navigation target, or
null if the agent is not navigating.true while the agent is crossing a NavMeshLink.Methods
| Method | Description |
|---|---|
MoveTo(Vector3 targetPosition) | Requests a path to targetPosition and starts navigating. Spam-safe — duplicate calls for the same destination are ignored. |
Stop() | Cancels the current navigation target and stops the agent. |
SetAgentPosition(Vector3 position) | Teleports the agent to a new position on the NavMesh. |
SetPath(NavMeshPath path) | Assigns a pre-calculated path for the agent to follow. |
GetPath() | Returns the agent’s current path as a NavMeshPath. Avoid calling every frame. |
GetLookAhead(float distance) | Returns a point on the current path distance units ahead of the agent. Useful for smooth rotation. |
CompleteLinkTraversal() | Signals that a manual link traversal is complete. Only needed when AutoTraverseLinks is false. |
Events
Fired when the agent begins traversing a
NavMeshLink.Fired when the agent finishes traversing a
NavMeshLink.NavMeshArea
NavMeshArea defines a volume that modifies NavMesh generation. Use it to block off rooms, mark hazardous zones, or tag areas with custom area types so agents can filter them.
When
true, NavMesh generation is completely disabled inside this volume. No agent can path through it.The area type to apply to the volume. Agents can allow or forbid specific area types via
AllowedAreas / ForbiddenAreas. Ignored when IsBlocker is true.NavMeshArea extends VolumeComponent. The volume’s shape is defined by the scene volume geometry attached to the same GameObject.NavMeshLink
NavMeshLink creates an off-mesh connection between two points, letting agents path through gaps that the baked mesh does not bridge — for example a ladder, a jump pad, or a doorway.
Start point of the link, relative to the GameObject’s origin.
End point of the link, relative to the GameObject’s origin.
When
true, agents can traverse the link in both directions. When false, traversal is only allowed from start to end.Search radius used at each end to find the nearest NavMesh polygon to connect to.
The area type assigned to this link. Agents that have this area in their
ForbiddenAreas will not use the link.The start endpoint snapped to the nearest NavMesh polygon.
null if the start is not connected.The end endpoint snapped to the nearest NavMesh polygon.
null if the end is not connected.Events
Fired when an agent enters this link.
Fired when an agent exits this link.
Example: simple NPC follower
The following component makes an NPC continuously follow the player. It combinesNavMeshAgent with CharacterController so the agent’s wish velocity feeds into physics-aware movement.