AI Navmesh Agent

Abhishek Smith

Abhishek Smith

Building Outscal | Land Jobs in the gaming industry | EA, Epic Games, TCS, | CMU, IIT K

Agent Movement Control

SetDestination: Set the destination for the agent

isStopped: Emergency brake for your agent

speed & angularSpeed: Fine-tune movement

acceleration: Control how quickly agent speeds up/slows down

radius: Set collision detection size

Move: Direct control when needed


State & Information

remainingDistance: How far to go

pathPending: Is path still calculating?

pathStatus: Current navigation status

nextPosition: Where agent heads next

hasPath: Valid path check

autoBraking: Control stopping behavior


Pathfinding & Queries

CalculatePath: Manual path planning

NavMesh.SamplePosition: Find valid NavMesh positions

path: Assign custom navigation paths

NavMesh.AddNavMeshData: Dynamic NavMesh updates


OffMeshLink Features

isOnOffMeshLink: Check special path segments

currentOffMeshLinkData: Get link details

ActivateCurrentOffMeshLink(bool): Enable/disable link traversal

CompleteOffMeshLink: Finish special path segment

autoTraverseOffMeshLink: Automatic link handling


Advanced Control

avoidancePriority: Agent collision importance

obstacleAvoidanceType: Quality vs Performance

Warp: Instant position changes

areaMask: Control walkable areas

stoppingDistance: Fine-tune arrival precision


CRITICAL Pro Tips

Cache your NavMeshAgent reference in Awake()

Always check pathStatus before moving

Use NavMesh.SamplePosition before SetDestination

Handle OffMeshLinks for jumps/teleports

Configure stopping distance carefully

Check isStopped && !pathPending to detect obstacles

Consider NavMeshObstacle carving performance impact


Common Pitfalls

  • Setting destination every frame
  • Ignoring path validation
  • Mishandling OffMeshLink activation (forgot the bool parameter)
  • Wrong avoidance settings in crowds
  • Forgetting to clear paths with ResetPath()
  • Not handling pathPending status
  • Assuming positions are valid without SamplePosition check

Show More