Intro
NavMesh (Navigation Mesh) is Unity’s core system for AI navigation. It defines walkable areas as a collection of 2D convex polygons, which agents then traverse using algorithms like A*.
NavMesh API
Baking a NavMesh generates this navigation mesh for all walkable areas in the scene, creating a precomputed map that agents use for pathfinding and spatial queries. Without baking, these operations cannot be performed.
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
NavMesh Agent
A NavMeshAgent is a GameObject that moves along the NavMesh using pathfinding and avoidance. It is represented as an upright cylinder, which is used to detect collisions with obstacles and other agents.
![]()
The NavMesh agent is a GameObject that is represented by an upright cylinder whose size is specified by the Radius and Height properties. The cylinder moves with the GameObject, but remains upright even if the GameObject rotates. The shape of the cylinder is used to detect and respond to collisions with other agents and obstacles. When the anchor point of the GameObject is not at the base of the cylinder, use the Base Offset property to specify the height difference.




