Determine what the user needs and guide them through navigation setup. See navigation-system.md for expanded component details, API notes, code recipes, and troubleshooting.
Passing C# to eval
eval compiles a statement block, not a file. Two consequences, both of which cause a
compile error rather than a warning:
- No
using directives. The compiler reads using UnityEngine; as a resource-disposal
statement and rejects it (CS0210).
- Types must be fully qualified. A bare
AssetDatabase or Volume does not resolve
(CS0246 / CS0103), and a bare Object is ambiguous with object (CS0104).
Where a snippet below is written as a file — with usings, for readability, or because it is
meant to be saved into the project — qualify the types before passing it to eval.
Routing Logic
| User Says |
Interpretation |
| "add navigation" / "set up nav" |
Full setup: NavMeshSurface + bake + NavMeshAgent |
| "make this character navigate" |
Add NavMeshAgent, ensure NavMesh exists |
| "add pathfinding" |
NavMeshAgent + movement script |
| "agent won't move" / "path not found" |
Troubleshoot — see Troubleshooting Decision Tree in reference |
| "avoid obstacles" |
NavMeshObstacle with carving or avoidance |
| "connect two areas" / "jump across" |
NavMeshLink between areas |
| "patrol between points" |
NavMeshAgent + patrol script |
| "click to move" |
NavMeshAgent + raycast click-to-move script |
| "animate the character while navigating" |
Couple Animator with NavMeshAgent |
| "different agent sizes" |
Configure agent types in Navigation window |
| "areas and costs" / "restrict areas" |
NavMesh area types, modifiers, and agent area masks |
Workflow
0. Package Installation Check
Before doing anything else, verify that com.unity.ai.navigation is installed. If it's missing,
add it to Packages/manifest.json under dependencies — Unity resolves it when the Editor next
regains focus, and this needs no Editor connection:
"com.unity.ai.navigation": "<current 2.x version>"
Don't invent the version string. Read the current one from the Unity registry —
https://packages.unity.com/com.unity.ai.navigation lists every published version — or copy the version an
adjacent Unity package in this manifest already uses. A version that doesn't exist makes
Unity fail resolution silently, so a wrong guess looks like nothing happened.
Proceed only once it's confirmed installed. If you have a live Editor to run C# in, see
navigation-system.md for the Client.Add equivalent.
1. Pre-Flight: Assess Current Navigation Setup
Before making changes, inspect what already exists:
- Find the existing navigation components. With a connected Editor, query the live scene for
NavMeshSurface, NavMeshAgent, NavMeshObstacle, NavMeshLink and NavMeshModifier — see
the unity-cli skill for driving a running Editor. Without one, search the scene and prefab
files for those component names.
- Check configured agent types via Window > AI > Navigation > Agents tab.
- Summarize ALL detected navigation components before proposing changes.
2. Gather Missing Information
Before creating components, ensure the user has specified: walkable surfaces, agent type/size, agent behavior, obstacles, links, and area/cost requirements. Ask if anything is unclear. See the Information Gathering Checklist in the reference for full details.
3. Planning & Execution
Follow this general order. See the Component Setup Guide in the reference for detailed step-by-step instructions per component:
- NavMesh Surface — create the walkable mesh (bake it)
- NavMesh Agent — add pathfinding characters
- NavMesh Obstacle — add dynamic obstacles
- NavMesh Link — connect disconnected NavMesh areas
- NavMesh Modifier / Modifier Volume — fine-tune area types
- Scripts — movement, patrol, click-to-move, animation coupling (see Common Recipes in reference)
4. Validation
After setup, confirm:
- NavMesh is baked and visible (blue overlay)
- NavMeshSurface agent type matches NavMeshAgent agent type
- Agents have a valid path to their destination
- Obstacles carve or obstruct correctly
- Links have both ends connected and Activated is enabled
- Area masks allow the intended movement
- No conflicting components (see Mixing Components Guide in reference)
- If using Rigidbody with NavMeshAgent, Is Kinematic is enabled
5. Final Confirmation
Summarize what was created or changed:
- NavMesh Surfaces: which GameObject, agent type, geometry mode, bake status
- NavMesh Agent(s): which GameObject, speed, stopping distance, area mask
- NavMesh Obstacle(s): which GameObject, shape, carve on/off
- NavMesh Link(s): start/end, bidirectional, area type
- Scripts: which scripts attached to which GameObjects
- Any manual steps required (adjust waypoints, re-bake after scene changes, etc.)
1---2name: initialize-ai-navigation3description: Sets up and configures the Unity AI Navigation system — NavMesh surfaces, NavMesh agents, obstacles, links, modifiers, areas and costs. Use when creating walkable navigation meshes, adding pathfinding agents, setting up patrol routes, configuring obstacle avoidance and carving, connecting separate NavMeshes with links, coupling navigation with animation, or troubleshooting navigation issues.4---5
6Determine what the user needs and guide them through navigation setup. See [navigation-system.md](references/navigation-system.md) for expanded component details, API notes, code recipes, and troubleshooting.
7
8### Passing C# to `eval`
9
10`eval` compiles a **statement block, not a file**. Two consequences, both of which cause a
11compile error rather than a warning:
12
13- **No `using` directives.** The compiler reads `using UnityEngine;` as a resource-disposal
14 statement and rejects it (`CS0210`).
15- **Types must be fully qualified.** A bare `AssetDatabase` or `Volume` does not resolve
16 (`CS0246` / `CS0103`), and a bare `Object` is ambiguous with `object` (`CS0104`).
17
18Where a snippet below is written as a file — with usings, for readability, or because it is
19meant to be saved into the project — qualify the types before passing it to `eval`.
20
21## Routing Logic
22
23| User Says | Interpretation |
24|-----------|---------------|
25| "add navigation" / "set up nav" | Full setup: NavMeshSurface + bake + NavMeshAgent |
26| "make this character navigate" | Add NavMeshAgent, ensure NavMesh exists |
27| "add pathfinding" | NavMeshAgent + movement script |
28| "agent won't move" / "path not found" | Troubleshoot — see Troubleshooting Decision Tree in reference |
29| "avoid obstacles" | NavMeshObstacle with carving or avoidance |
30| "connect two areas" / "jump across" | NavMeshLink between areas |
31| "patrol between points" | NavMeshAgent + patrol script |
32| "click to move" | NavMeshAgent + raycast click-to-move script |
33| "animate the character while navigating" | Couple Animator with NavMeshAgent |
34| "different agent sizes" | Configure agent types in Navigation window |
35| "areas and costs" / "restrict areas" | NavMesh area types, modifiers, and agent area masks |
36
37## Workflow
38
39### 0. Package Installation Check
40Before doing anything else, verify that `com.unity.ai.navigation` is installed. If it's missing,
41add it to `Packages/manifest.json` under `dependencies` — Unity resolves it when the Editor next
42regains focus, and this needs no Editor connection:
43
44```json
45"com.unity.ai.navigation": "<current 2.x version>"
46```
47
48Don't invent the version string. Read the current one from the Unity registry —
49`https://packages.unity.com/com.unity.ai.navigation` lists every published version — or copy the version an
50adjacent Unity package in this manifest already uses. A version that doesn't exist makes
51Unity fail resolution **silently**, so a wrong guess looks like nothing happened.
52
53Proceed only once it's confirmed installed. If you have a live Editor to run C# in, see
54[navigation-system.md](references/navigation-system.md) for the `Client.Add` equivalent.
55
56### 1. Pre-Flight: Assess Current Navigation Setup
57Before making changes, inspect what already exists:
581. Find the existing navigation components. With a connected Editor, query the live scene for
59 `NavMeshSurface`, `NavMeshAgent`, `NavMeshObstacle`, `NavMeshLink` and `NavMeshModifier` — see
60 the `unity-cli` skill for driving a running Editor. Without one, search the scene and prefab
61 files for those component names.
622. Check configured agent types via **Window > AI > Navigation > Agents tab**.
633. Summarize ALL detected navigation components before proposing changes.
64
65### 2. Gather Missing Information
66Before creating components, ensure the user has specified: walkable surfaces, agent type/size, agent behavior, obstacles, links, and area/cost requirements. Ask if anything is unclear. See the Information Gathering Checklist in the reference for full details.
67
68### 3. Planning & Execution
69Follow this general order. See the Component Setup Guide in the reference for detailed step-by-step instructions per component:
701. **NavMesh Surface** — create the walkable mesh (bake it)
712. **NavMesh Agent** — add pathfinding characters
723. **NavMesh Obstacle** — add dynamic obstacles
734. **NavMesh Link** — connect disconnected NavMesh areas
745. **NavMesh Modifier / Modifier Volume** — fine-tune area types
756. **Scripts** — movement, patrol, click-to-move, animation coupling (see Common Recipes in reference)
76
77### 4. Validation
78After setup, confirm:
79- NavMesh is baked and visible (blue overlay)
80- NavMeshSurface agent type matches NavMeshAgent agent type
81- Agents have a valid path to their destination
82- Obstacles carve or obstruct correctly
83- Links have both ends connected and Activated is enabled
84- Area masks allow the intended movement
85- No conflicting components (see Mixing Components Guide in reference)
86- If using Rigidbody with NavMeshAgent, Is Kinematic is enabled
87
88### 5. Final Confirmation
89Summarize what was created or changed:
90- NavMesh Surfaces: which GameObject, agent type, geometry mode, bake status
91- NavMesh Agent(s): which GameObject, speed, stopping distance, area mask
92- NavMesh Obstacle(s): which GameObject, shape, carve on/off
93- NavMesh Link(s): start/end, bidirectional, area type
94- Scripts: which scripts attached to which GameObjects
95- Any manual steps required (adjust waypoints, re-bake after scene changes, etc.)