nccgs 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (278) hide show
  1. package/.claude/agents/nccgs-accessibility-specialist.md +26 -0
  2. package/.claude/agents/nccgs-adversarial-reviewer.md +26 -0
  3. package/.claude/agents/nccgs-ai-programmer.md +26 -0
  4. package/.claude/agents/nccgs-analytics-engineer.md +26 -0
  5. package/.claude/agents/nccgs-art-direction-lead.md +26 -0
  6. package/.claude/agents/nccgs-audio-direction-lead.md +26 -0
  7. package/.claude/agents/nccgs-creative-director.md +26 -0
  8. package/.claude/agents/nccgs-documentation-manager.md +26 -0
  9. package/.claude/agents/nccgs-economy-designer.md +26 -0
  10. package/.claude/agents/nccgs-engine-programmer.md +26 -0
  11. package/.claude/agents/nccgs-game-design-lead.md +26 -0
  12. package/.claude/agents/nccgs-game-designer.md +26 -0
  13. package/.claude/agents/nccgs-gameplay-programmer.md +26 -0
  14. package/.claude/agents/nccgs-level-designer.md +26 -0
  15. package/.claude/agents/nccgs-live-ops-designer.md +26 -0
  16. package/.claude/agents/nccgs-localization-lead.md +26 -0
  17. package/.claude/agents/nccgs-narrative-lead.md +26 -0
  18. package/.claude/agents/nccgs-network-programmer.md +26 -0
  19. package/.claude/agents/nccgs-performance-analyst.md +26 -0
  20. package/.claude/agents/nccgs-producer.md +26 -0
  21. package/.claude/agents/nccgs-production-coordinator.md +23 -0
  22. package/.claude/agents/nccgs-programming-lead.md +26 -0
  23. package/.claude/agents/nccgs-prototyper.md +26 -0
  24. package/.claude/agents/nccgs-qa-engineer.md +26 -0
  25. package/.claude/agents/nccgs-qa-lead.md +26 -0
  26. package/.claude/agents/nccgs-release-engineer.md +26 -0
  27. package/.claude/agents/nccgs-release-lead.md +26 -0
  28. package/.claude/agents/nccgs-security-engineer.md +26 -0
  29. package/.claude/agents/nccgs-sound-designer.md +26 -0
  30. package/.claude/agents/nccgs-systems-designer.md +26 -0
  31. package/.claude/agents/nccgs-technical-architect.md +26 -0
  32. package/.claude/agents/nccgs-technical-artist.md +26 -0
  33. package/.claude/agents/nccgs-technical-director.md +26 -0
  34. package/.claude/agents/nccgs-tools-programmer.md +26 -0
  35. package/.claude/agents/nccgs-ui-programmer.md +26 -0
  36. package/.claude/agents/nccgs-unity-build-specialist.md +26 -0
  37. package/.claude/agents/nccgs-unity-content-specialist.md +26 -0
  38. package/.claude/agents/nccgs-unity-implementer.md +26 -0
  39. package/.claude/agents/nccgs-unity-rendering-specialist.md +26 -0
  40. package/.claude/agents/nccgs-unity-systems-specialist.md +26 -0
  41. package/.claude/agents/nccgs-unity-ui-specialist.md +26 -0
  42. package/.claude/agents/nccgs-ux-designer.md +26 -0
  43. package/.claude/agents/nccgs-verification-engineer.md +26 -0
  44. package/.claude/agents/nccgs-world-builder.md +26 -0
  45. package/.claude/agents/nccgs-writer.md +26 -0
  46. package/.claude/nccgs/THIRD_PARTY_NOTICES.md +13 -0
  47. package/.claude/nccgs/VERSION +1 -0
  48. package/.claude/nccgs/constitution.md +131 -0
  49. package/.claude/nccgs/hooks/agent-audit.mjs +10 -0
  50. package/.claude/nccgs/hooks/common.mjs +41 -0
  51. package/.claude/nccgs/hooks/post-compact.mjs +1 -0
  52. package/.claude/nccgs/hooks/pre-compact.mjs +8 -0
  53. package/.claude/nccgs/hooks/protect-git.mjs +22 -0
  54. package/.claude/nccgs/hooks/protect-write.mjs +17 -0
  55. package/.claude/nccgs/hooks/session-start.mjs +15 -0
  56. package/.claude/nccgs/hooks/session-stop.mjs +7 -0
  57. package/.claude/nccgs/protocols/agent-contract.md +34 -0
  58. package/.claude/nccgs/protocols/context-packets.md +13 -0
  59. package/.claude/nccgs/protocols/evidence.md +15 -0
  60. package/.claude/nccgs/protocols/model-routing.md +22 -0
  61. package/.claude/nccgs/protocols/orchestration.md +26 -0
  62. package/.claude/nccgs/protocols/unity-boundary.md +11 -0
  63. package/.claude/nccgs/settings.fragment.json +77 -0
  64. package/.claude/nccgs/studio.json +347 -0
  65. package/.claude/nccgs/tools/configure-models.mjs +39 -0
  66. package/.claude/nccgs/unity-skills-manifest.json +727 -0
  67. package/.claude/nccgs/workflow-catalog.json +317 -0
  68. package/.claude/rules/nccgs-canonical-docs.md +19 -0
  69. package/.claude/rules/nccgs-editor-tools.md +12 -0
  70. package/.claude/rules/nccgs-localization.md +12 -0
  71. package/.claude/rules/nccgs-networking.md +13 -0
  72. package/.claude/rules/nccgs-performance.md +14 -0
  73. package/.claude/rules/nccgs-rendering.md +16 -0
  74. package/.claude/rules/nccgs-security.md +13 -0
  75. package/.claude/rules/nccgs-tests.md +18 -0
  76. package/.claude/rules/nccgs-ui.md +14 -0
  77. package/.claude/rules/nccgs-unity-assets.md +21 -0
  78. package/.claude/rules/nccgs-unity-code.md +22 -0
  79. package/.claude/skills/accessibility-review/SKILL.md +14 -0
  80. package/.claude/skills/architecture-decision/SKILL.md +14 -0
  81. package/.claude/skills/asset-audit/SKILL.md +14 -0
  82. package/.claude/skills/audit/SKILL.md +16 -0
  83. package/.claude/skills/audit/references/dimensions.md +46 -0
  84. package/.claude/skills/balance-review/SKILL.md +14 -0
  85. package/.claude/skills/bug-triage/SKILL.md +14 -0
  86. package/.claude/skills/build-live-game/SKILL.md +317 -0
  87. package/.claude/skills/build-live-game/references/achievements.md +779 -0
  88. package/.claude/skills/build-live-game/references/apis.md +280 -0
  89. package/.claude/skills/build-live-game/references/authentication.md +437 -0
  90. package/.claude/skills/build-live-game/references/battlepass.md +860 -0
  91. package/.claude/skills/build-live-game/references/cloud-code.md +563 -0
  92. package/.claude/skills/build-live-game/references/cloud-save.md +474 -0
  93. package/.claude/skills/build-live-game/references/deployment.md +216 -0
  94. package/.claude/skills/build-live-game/references/player-account.md +813 -0
  95. package/.claude/skills/build-live-game/references/remote-config.md +96 -0
  96. package/.claude/skills/build-live-game/references/tooling.md +431 -0
  97. package/.claude/skills/closure/SKILL.md +14 -0
  98. package/.claude/skills/code-review/SKILL.md +14 -0
  99. package/.claude/skills/compatibility-review/SKILL.md +14 -0
  100. package/.claude/skills/context-pack/SKILL.md +14 -0
  101. package/.claude/skills/dependency-review/SKILL.md +14 -0
  102. package/.claude/skills/design/SKILL.md +20 -0
  103. package/.claude/skills/design-review/SKILL.md +14 -0
  104. package/.claude/skills/evidence-review/SKILL.md +14 -0
  105. package/.claude/skills/hotfix/SKILL.md +14 -0
  106. package/.claude/skills/implement-in-app-purchases/README.md +233 -0
  107. package/.claude/skills/implement-in-app-purchases/SKILL.md +158 -0
  108. package/.claude/skills/implement-in-app-purchases/references/api-notes.md +562 -0
  109. package/.claude/skills/implement-in-app-purchases/references/codeless-catalog.md +331 -0
  110. package/.claude/skills/implement-in-app-purchases/references/convert-adapty.md +268 -0
  111. package/.claude/skills/implement-in-app-purchases/references/convert-essentialkit.md +239 -0
  112. package/.claude/skills/implement-in-app-purchases/references/convert-revenuecat.md +275 -0
  113. package/.claude/skills/implement-in-app-purchases/references/convert-unipay.md +145 -0
  114. package/.claude/skills/implement-in-app-purchases/references/migration-v4-to-v5.md +204 -0
  115. package/.claude/skills/implement-in-app-purchases/references/path-add-iap-to-new-project.md +198 -0
  116. package/.claude/skills/implement-in-app-purchases/references/path-convert-native-google-billing.md +356 -0
  117. package/.claude/skills/implement-in-app-purchases/references/path-convert-native-storekit.md +446 -0
  118. package/.claude/skills/implement-in-app-purchases/references/path-implement-iap-d2c.md +680 -0
  119. package/.claude/skills/implement-in-app-purchases/references/platform-notes.md +204 -0
  120. package/.claude/skills/implement-in-app-purchases/references/pre-check.md +205 -0
  121. package/.claude/skills/incident-recovery/SKILL.md +14 -0
  122. package/.claude/skills/initialize-ai-navigation/SKILL.md +95 -0
  123. package/.claude/skills/initialize-ai-navigation/references/navigation-system.md +794 -0
  124. package/.claude/skills/levelplay-unity-integration/CHANGELOG.md +57 -0
  125. package/.claude/skills/levelplay-unity-integration/README.md +74 -0
  126. package/.claude/skills/levelplay-unity-integration/SKILL.md +1126 -0
  127. package/.claude/skills/levelplay-unity-integration/references/banner-api.md +920 -0
  128. package/.claude/skills/levelplay-unity-integration/references/best-practices.md +536 -0
  129. package/.claude/skills/levelplay-unity-integration/references/ilrd-api.md +337 -0
  130. package/.claude/skills/levelplay-unity-integration/references/initialization-api.md +630 -0
  131. package/.claude/skills/levelplay-unity-integration/references/interstitial-api.md +899 -0
  132. package/.claude/skills/levelplay-unity-integration/references/ios-setup.md +491 -0
  133. package/.claude/skills/levelplay-unity-integration/references/migration-sdk-9.md +666 -0
  134. package/.claude/skills/levelplay-unity-integration/references/privacy-settings.md +608 -0
  135. package/.claude/skills/levelplay-unity-integration/references/rewarded-api.md +902 -0
  136. package/.claude/skills/localization/SKILL.md +135 -0
  137. package/.claude/skills/localization/references/api-notes.md +76 -0
  138. package/.claude/skills/localization/resources/L10nBatchProcessor.cs +69 -0
  139. package/.claude/skills/localization/resources/LocalizedFontAsset.cs +18 -0
  140. package/.claude/skills/localize-game/SKILL.md +14 -0
  141. package/.claude/skills/migrate-project/SKILL.md +21 -0
  142. package/.claude/skills/migrate-project/references/procedure.md +63 -0
  143. package/.claude/skills/milestone-review/SKILL.md +14 -0
  144. package/.claude/skills/new-unity-project/SKILL.md +179 -0
  145. package/.claude/skills/optimize-audio/SKILL.md +199 -0
  146. package/.claude/skills/optimize-audio/resources/audio-import-api.md +146 -0
  147. package/.claude/skills/optimize-audio/resources/platform-settings.md +48 -0
  148. package/.claude/skills/optimize-text-mesh-pro/SKILL.md +182 -0
  149. package/.claude/skills/optimize-web/SKILL.md +393 -0
  150. package/.claude/skills/optimize-web/resources/WebOptimizer.cs +21 -0
  151. package/.claude/skills/optimize-web/resources/toktx-examples.sh +11 -0
  152. package/.claude/skills/performance-audit/SKILL.md +14 -0
  153. package/.claude/skills/physics-3d-collision/SKILL.md +442 -0
  154. package/.claude/skills/physics-3d-collision/references/troubleshooting.md +41 -0
  155. package/.claude/skills/physics-3d-collision/resources/CollisionDebugger.cs +33 -0
  156. package/.claude/skills/plan-feature/SKILL.md +14 -0
  157. package/.claude/skills/playtest/SKILL.md +14 -0
  158. package/.claude/skills/project-stage/SKILL.md +14 -0
  159. package/.claude/skills/prototype-feature/SKILL.md +14 -0
  160. package/.claude/skills/qa-plan/SKILL.md +14 -0
  161. package/.claude/skills/release/SKILL.md +18 -0
  162. package/.claude/skills/release-readiness/SKILL.md +14 -0
  163. package/.claude/skills/retrospective/SKILL.md +14 -0
  164. package/.claude/skills/review/SKILL.md +16 -0
  165. package/.claude/skills/security-audit/SKILL.md +14 -0
  166. package/.claude/skills/setup-multiplayer-services/SKILL.md +39 -0
  167. package/.claude/skills/setup-multiplayer-services/references/dgs-entrypoint.md +79 -0
  168. package/.claude/skills/setup-multiplayer-services/references/entrypoints.md +213 -0
  169. package/.claude/skills/setup-multiplayer-services/references/examples.md +33 -0
  170. package/.claude/skills/setup-multiplayer-services/references/implementation-fit.md +30 -0
  171. package/.claude/skills/setup-multiplayer-services/references/underlying-services.md +11 -0
  172. package/.claude/skills/setup-multiplayer-services/references/workflows-prerequisites.md +17 -0
  173. package/.claude/skills/setup-vivox-voice-chat/SKILL.md +118 -0
  174. package/.claude/skills/setup-vivox-voice-chat/evals/.env.example +6 -0
  175. package/.claude/skills/setup-vivox-voice-chat/evals/README.md +101 -0
  176. package/.claude/skills/setup-vivox-voice-chat/evals/promptfooconfig.yaml +32 -0
  177. package/.claude/skills/setup-vivox-voice-chat/evals/tests/init-and-login.yaml +76 -0
  178. package/.claude/skills/setup-vivox-voice-chat/evals/tests/text-chat.yaml +65 -0
  179. package/.claude/skills/setup-vivox-voice-chat/evals/tests/voice-channels.yaml +74 -0
  180. package/.claude/skills/setup-vivox-voice-chat/references/events-and-participants.md +79 -0
  181. package/.claude/skills/setup-vivox-voice-chat/references/init-and-login.md +92 -0
  182. package/.claude/skills/setup-vivox-voice-chat/references/text-chat.md +93 -0
  183. package/.claude/skills/setup-vivox-voice-chat/references/troubleshooting.md +47 -0
  184. package/.claude/skills/setup-vivox-voice-chat/references/voice-channels.md +90 -0
  185. package/.claude/skills/shader-graph-create-custom-node/SKILL.md +25 -0
  186. package/.claude/skills/shader-graph-create-custom-node/resources/all_hints.hlsl +182 -0
  187. package/.claude/skills/sprint-plan/SKILL.md +14 -0
  188. package/.claude/skills/sprite-editor/SKILL.md +66 -0
  189. package/.claude/skills/sprite-editor/references/api_reference.md +151 -0
  190. package/.claude/skills/sprite-editor/references/background.md +112 -0
  191. package/.claude/skills/sprite-editor/references/templates.md +72 -0
  192. package/.claude/skills/sprite-editor/scripts/AutomaticSliceTexture.cs +40 -0
  193. package/.claude/skills/sprite-editor/scripts/GenerateNewSpriteRects.cs +200 -0
  194. package/.claude/skills/sprite-editor/scripts/GetTextureSourceImageSize.cs +32 -0
  195. package/.claude/skills/sprite-editor/scripts/GetTextureToSlice.cs +55 -0
  196. package/.claude/skills/sprite-editor/scripts/GridSliceTexture.cs +40 -0
  197. package/.claude/skills/sprite-editor/scripts/IsometricSliceTexture.cs +141 -0
  198. package/.claude/skills/sprite-editor/scripts/README.md +134 -0
  199. package/.claude/skills/sprite-editor/scripts/SetPivotExample.cs +58 -0
  200. package/.claude/skills/sprite-editor/scripts/SpriteToPng.cs +88 -0
  201. package/.claude/skills/status/SKILL.md +16 -0
  202. package/.claude/skills/story-readiness/SKILL.md +14 -0
  203. package/.claude/skills/test/SKILL.md +16 -0
  204. package/.claude/skills/ui/SKILL.md +142 -0
  205. package/.claude/skills/ui-imgui/SKILL.md +186 -0
  206. package/.claude/skills/ui-imgui/references/gui-elements.md +156 -0
  207. package/.claude/skills/ui-imgui/references/templates.md +141 -0
  208. package/.claude/skills/ui-review/SKILL.md +14 -0
  209. package/.claude/skills/ui-ugui/SKILL.md +282 -0
  210. package/.claude/skills/ui-ugui/references/scrollview-setup.md +29 -0
  211. package/.claude/skills/ui-uitk/SKILL.md +235 -0
  212. package/.claude/skills/ui-uitk/references/common-issues.md +74 -0
  213. package/.claude/skills/ui-uitk/references/custom-elements.md +241 -0
  214. package/.claude/skills/ui-uitk/references/painter2d.md +282 -0
  215. package/.claude/skills/ui-uitk/references/pointermanipulator-guide.md +94 -0
  216. package/.claude/skills/ui-uitk/references/svg-icons.md +136 -0
  217. package/.claude/skills/ui-uitk/references/ui-runtime-binding.md +234 -0
  218. package/.claude/skills/ui-uitk/references/uss-guide.md +138 -0
  219. package/.claude/skills/unity-cli/CHANGELOG.md +233 -0
  220. package/.claude/skills/unity-cli/SECURITY.md +22 -0
  221. package/.claude/skills/unity-cli/SKILL.md +414 -0
  222. package/.claude/skills/unity-cli/references/auth-license-cloud.md +146 -0
  223. package/.claude/skills/unity-cli/references/build-run-test.md +349 -0
  224. package/.claude/skills/unity-cli/references/collaboration.md +472 -0
  225. package/.claude/skills/unity-cli/references/config-hub.md +103 -0
  226. package/.claude/skills/unity-cli/references/diagnostics-maintenance.md +326 -0
  227. package/.claude/skills/unity-cli/references/editors-install.md +327 -0
  228. package/.claude/skills/unity-cli/references/integration-advanced.md +472 -0
  229. package/.claude/skills/unity-cli/references/projects-templates.md +574 -0
  230. package/.claude/skills/unity-package-management/SKILL.md +304 -0
  231. package/.claude/skills/unity-package-management/references/select-packages.md +108 -0
  232. package/.claude/skills/urp-postprocessing/SKILL.md +188 -0
  233. package/.claude/skills/urp-postprocessing/references/code-templates.md +119 -0
  234. package/.claude/skills/urp-postprocessing/references/effect-reference.md +86 -0
  235. package/.claude/skills/validate-urp-render-graph-renderer-feature/SKILL.md +269 -0
  236. package/.claude/skills/work/SKILL.md +36 -0
  237. package/.claude/skills/work/references/classification.md +41 -0
  238. package/.claude/skills/work/references/closure.md +50 -0
  239. package/.claude/skills/work/references/feature-contracts.md +32 -0
  240. package/.claude/skills/work/references/verification.md +26 -0
  241. package/CLAUDE.md +6 -0
  242. package/LICENSE +21 -0
  243. package/README.md +162 -0
  244. package/THIRD_PARTY_NOTICES.md +23 -0
  245. package/UPGRADING.md +32 -0
  246. package/VERSION +1 -0
  247. package/docs/ARCHITECTURE.md +73 -0
  248. package/docs/HUONG-DAN-MIGRATE-VA-SU-DUNG.md +324 -0
  249. package/docs/MIGRATION-MATRIX.md +23 -0
  250. package/docs/PROJECT-POLICY.md +67 -0
  251. package/docs/WORKFLOWS.md +61 -0
  252. package/package-assets/setup-vivox-voice-chat-evals.gitignore +7 -0
  253. package/package.json +41 -0
  254. package/scaffold/.nccgs/bugs/.gitkeep +1 -0
  255. package/scaffold/.nccgs/closures/.gitkeep +1 -0
  256. package/scaffold/.nccgs/context/.gitkeep +1 -0
  257. package/scaffold/.nccgs/decisions/.gitkeep +1 -0
  258. package/scaffold/.nccgs/evidence/.gitkeep +1 -0
  259. package/scaffold/.nccgs/features/.gitkeep +1 -0
  260. package/scaffold/.nccgs/migrations/.gitkeep +1 -0
  261. package/scaffold/.nccgs/playtests/.gitkeep +1 -0
  262. package/scaffold/.nccgs/project.yaml +103 -0
  263. package/scaffold/.nccgs/requirements.yaml +10 -0
  264. package/scaffold/.nccgs/reviews/.gitkeep +1 -0
  265. package/scaffold/.nccgs/state.md +40 -0
  266. package/scaffold/.nccgs/templates/agent-handoff.md +25 -0
  267. package/scaffold/.nccgs/templates/architecture-decision.md +27 -0
  268. package/scaffold/.nccgs/templates/closure-record.md +51 -0
  269. package/scaffold/.nccgs/templates/context-packet.yaml +17 -0
  270. package/scaffold/.nccgs/templates/evidence-record.md +23 -0
  271. package/scaffold/.nccgs/templates/feature-contract.md +35 -0
  272. package/scaffold/.nccgs/templates/migration-plan.md +40 -0
  273. package/scaffold/.nccgs/templates/waiver.md +11 -0
  274. package/scripts/cli.mjs +56 -0
  275. package/scripts/install.mjs +267 -0
  276. package/scripts/sync-unity-skills.mjs +126 -0
  277. package/scripts/validate.mjs +205 -0
  278. package/tests/framework.test.mjs +121 -0
@@ -0,0 +1,794 @@
1
+ #> **Which snippets go where.** The recipes below — movement, patrol, click-to-move, animation
2
+ > coupling, path inspection — are **written as game scripts**: save them into the project with
3
+ > their `using UnityEngine.AI;` and short type names intact. Only the Editor-side operations
4
+ > (installing the package, querying the live scene) are meant to be passed to `eval`, and those
5
+ > are fully qualified because `eval` takes no usings.
6
+
7
+ # Table of Contents
8
+ - [Performance Notes](#performance-notes)
9
+ - [Information Gathering Checklist](#information-gathering-checklist)
10
+ - [Component Setup Guide](#component-setup-guide)
11
+ - [Common Recipes](#common-recipes)
12
+ - [Important API Notes](#important-api-notes)
13
+ - [Core Concepts Reference](#core-concepts-reference)
14
+ - [Component Reference — NavMesh Surface](#component-reference--navmesh-surface)
15
+ - [Component Reference — NavMesh Agent](#component-reference--navmesh-agent)
16
+ - [Component Reference — NavMesh Obstacle](#component-reference--navmesh-obstacle)
17
+ - [Component Reference — NavMesh Link](#component-reference--navmesh-link)
18
+ - [Component Reference — NavMesh Modifier](#component-reference--navmesh-modifier)
19
+ - [Component Reference — NavMesh Modifier Volume](#component-reference--navmesh-modifier-volume)
20
+ - [Navigation Areas and Costs](#navigation-areas-and-costs)
21
+ - [Mixing Components Guide](#mixing-components-guide)
22
+ - [Coupling Animation and Navigation](#coupling-animation-and-navigation)
23
+ - [Troubleshooting Decision Tree](#troubleshooting-decision-tree)
24
+ - [Common Mistakes to Avoid](#common-mistakes-to-avoid)
25
+
26
+
27
+ ## Performance Notes
28
+ - Do this thoroughly.
29
+ - Quality is more important than speed.
30
+ - Always inspect existing navigation setup before adding new components.
31
+
32
+
33
+ ## Information Gathering Checklist
34
+
35
+ Before creating components, ensure the following details exist. If not, ask the user:
36
+
37
+ ### Core Questions
38
+ * **What needs a NavMesh?** Which GameObjects or areas represent walkable surfaces? (floor, terrain, platforms)
39
+ * **Agent type:** What kind of characters navigate? (humanoid, large vehicle, small creature) — determines radius, height, step height, slope
40
+ * **Agent behavior:** What should agents do? (move to target, patrol, follow player, click-to-move)
41
+ * **Obstacles:** Are there dynamic obstacles agents must avoid? (crates, doors, vehicles)
42
+ * **Links:** Are there gaps, jumps, or disconnected areas that agents must cross?
43
+ * **Areas and costs:** Are there different terrain types with different traversal costs? (water, mud, roads)
44
+
45
+ ### Per-Agent Details
46
+ * **Speed:** Maximum movement speed (default: 3.5 units/sec)
47
+ * **Angular Speed:** Maximum rotation speed (default: 120 deg/sec)
48
+ * **Acceleration:** How quickly the agent reaches max speed (default: 8 units/sec²)
49
+ * **Stopping Distance:** How close the agent gets before stopping (default: 0)
50
+ * **Auto Braking:** Should the agent slow down near destination? (yes for move-to, no for patrol)
51
+
52
+
53
+ ## Component Setup Guide
54
+
55
+ ### NavMesh Surface (Walkable Area)
56
+
57
+ The NavMeshSurface component defines and builds the navigation mesh.
58
+
59
+ 1. **Select the geometry** that represents your walkable area (floor, terrain, or a parent containing all walkable children).
60
+ 2. **Add component:** `NavMeshSurface` via **Add Component > Navigation > NavMesh Surface**.
61
+ 3. **Configure:**
62
+ - **Agent Type:** Match the agent type that will use this NavMesh.
63
+ - **Default Area:** Usually "Walkable".
64
+ - **Use Geometry:** "Render Meshes" (visual geometry) or "Physics Colliders" (collision geometry — agents walk closer to edges).
65
+ - **Collect Objects:** "All Game Objects" (default), "Current Object Hierarchy" (only children of this GameObject), or "Volume" (within a bounding box).
66
+ - **Include Layers:** Filter which layers contribute to the NavMesh.
67
+ - **Generate Links:** Enable to auto-generate jump-across and drop-down links during bake.
68
+ 4. **Bake:** Click **Bake** in the Inspector. The NavMesh appears as a blue overlay.
69
+
70
+ **Multiple surfaces:** A scene can have multiple NavMeshSurface components for different agent types or different areas. Only enabled surfaces on active GameObjects load their NavMesh data.
71
+
72
+ **Runtime baking:** For procedural levels, call `NavMeshSurface.BuildNavMesh()` at runtime:
73
+ ```csharp
74
+ var surface = targetGameObject.GetComponent<NavMeshSurface>();
75
+ surface.BuildNavMesh();
76
+ Debug.Log("NavMesh baked at runtime.");
77
+ ```
78
+
79
+ ### NavMesh Agent (Pathfinding Character)
80
+
81
+ 1. **Select the character** GameObject.
82
+ 2. **Add component:** `NavMeshAgent` via **Add Component > Navigation > NavMesh Agent**.
83
+ 3. **Configure steering:**
84
+ - **Speed:** Match movement animation speed (default: 3.5).
85
+ - **Angular Speed:** 120 deg/sec is typical.
86
+ - **Acceleration:** 8 is responsive; lower for heavier characters.
87
+ - **Stopping Distance:** 0 for precise arrival; increase for loose following.
88
+ - **Auto Braking:** On for move-to-target; off for continuous patrol.
89
+ 4. **Configure obstacle avoidance:**
90
+ - **Radius:** Should match character width roughly.
91
+ - **Height:** Should match character height.
92
+ - **Quality:** High Quality for important agents; reduce for crowds.
93
+ - **Priority:** 0–99, lower = higher priority. Important agents push through crowds.
94
+ 5. **Configure pathfinding:**
95
+ - **Auto Traverse OffMesh Link:** On (unless custom link traversal is needed).
96
+ - **Auto Repath:** On for agents that should retry when paths are blocked.
97
+ - **Area Mask:** Select which area types this agent can use.
98
+
99
+ ### NavMesh Obstacle (Dynamic Blockers)
100
+
101
+ For physics-controlled or dynamic objects that agents should avoid:
102
+
103
+ 1. **Select the obstacle** GameObject.
104
+ 2. **Add component:** `NavMeshObstacle` via **Add Component > Navigation > NavMesh Obstacle**.
105
+ 3. **Configure:**
106
+ - **Shape:** Box or Capsule — pick whichever fits the object.
107
+ - **Center/Size:** Auto-fits to renderer; adjust if needed.
108
+ - **Carve:** Enable for stationary obstacles that should cut holes in the NavMesh.
109
+ - **Move Threshold:** Distance before the carved hole updates (default: 0.1).
110
+ - **Time To Stationary:** Seconds before the obstacle is considered stopped (default: 0.5).
111
+ - **Carve Only Stationary:** On for physics objects (best performance); off for large slow-moving obstacles like tanks.
112
+
113
+ **When to carve vs. obstruct:**
114
+ - **Moving obstacles** (vehicles, player): Leave Carve off — use local avoidance.
115
+ - **Stationary or semi-stationary obstacles** (crates, barrels, doors): Enable Carve — agents plan paths around them.
116
+
117
+ ### NavMesh Link (Bridge Disconnected Areas)
118
+
119
+ For jumps, drops, doors, or any shortcut that isn't walkable surface:
120
+
121
+ 1. **Create two marker objects** (empty GameObjects or small cylinders) at the link start and end positions.
122
+ 2. **Add component:** `NavMeshLink` to a GameObject via **Add Component > Navigation > NavMesh Link**.
123
+ 3. **Configure:**
124
+ - **Agent Type:** Which agent type can use this link.
125
+ - **Start Transform / End Transform:** Assign the marker objects.
126
+ - **Width:** 0 for point-to-point; positive for a span agents can enter along.
127
+ - **Bidirectional:** On for two-way traversal; off for one-way (e.g., drop-down only).
128
+ - **Area Type:** Usually "Jump" for auto-links; set custom type for doors etc.
129
+ - **Cost Override:** Override the traversal cost if needed.
130
+ - **Activated:** Must be on for agents to use the link.
131
+ 4. **Verify:** Both ends must connect to a NavMesh (visible as circles/dark edges in Scene view with NavMesh debug on).
132
+
133
+ **Auto-generated links:** Enable **Generate Links** on the NavMeshSurface and configure **Drop Height** and **Jump Distance** in the agent type settings (Window > AI > Navigation > Agents tab) for automatic link generation during bake.
134
+
135
+ ### NavMesh Modifier (Per-GameObject)
136
+ Adjusts how a specific GameObject (and optionally its children) contributes to the NavMesh:
137
+ - **Mode:** "Add or Modify Object" (include) or "Remove Object" (exclude from NavMesh).
138
+ - **Affected Agents:** Which agent types are affected.
139
+ - **Apply to Children:** Cascade to child hierarchy.
140
+ - **Override Area:** Change the area type for this object.
141
+ - **Override Generate Links:** Force include/exclude from link generation.
142
+
143
+ ### NavMesh Modifier Volume (Region-Based)
144
+ Changes the area type within a defined box volume:
145
+ - **Size / Center:** Define the box region.
146
+ - **Area Type:** The area type to stamp onto NavMeshes within this volume.
147
+ - **Affected Agents:** Which agent types are affected.
148
+
149
+ Use Modifier Volumes for areas that don't correspond to separate geometry (e.g., marking part of a floor as "Water" or "Not Walkable").
150
+
151
+
152
+ ## Common Recipes
153
+
154
+ ### Move to a Transform Target
155
+ ```csharp
156
+ using UnityEngine;
157
+ using UnityEngine.AI;
158
+
159
+ public class MoveToTarget : MonoBehaviour
160
+ {
161
+ public Transform goal;
162
+ NavMeshAgent agent;
163
+
164
+ void Start()
165
+ {
166
+ agent = GetComponent<NavMeshAgent>();
167
+ agent.destination = goal.position;
168
+ }
169
+ }
170
+ ```
171
+
172
+ ### Click-to-Move (Mouse Raycast)
173
+ ```csharp
174
+ using UnityEngine;
175
+ using UnityEngine.AI;
176
+
177
+ public class ClickToMove : MonoBehaviour
178
+ {
179
+ NavMeshAgent agent;
180
+
181
+ void Start()
182
+ {
183
+ agent = GetComponent<NavMeshAgent>();
184
+ }
185
+
186
+ void Update()
187
+ {
188
+ if (Input.GetMouseButtonDown(0))
189
+ {
190
+ if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out RaycastHit hit, 100f))
191
+ {
192
+ agent.destination = hit.point;
193
+ }
194
+ }
195
+ }
196
+ }
197
+ ```
198
+
199
+ ### Patrol Between Waypoints
200
+ ```csharp
201
+ using UnityEngine;
202
+ using UnityEngine.AI;
203
+
204
+ public class Patrol : MonoBehaviour
205
+ {
206
+ public Transform[] points;
207
+ int destPoint = 0;
208
+ NavMeshAgent agent;
209
+
210
+ void Start()
211
+ {
212
+ agent = GetComponent<NavMeshAgent>();
213
+ agent.autoBraking = false;
214
+ GotoNextPoint();
215
+ }
216
+
217
+ void GotoNextPoint()
218
+ {
219
+ if (points.Length == 0) return;
220
+ agent.destination = points[destPoint].position;
221
+ destPoint = (destPoint + 1) % points.Length;
222
+ }
223
+
224
+ void Update()
225
+ {
226
+ if (!agent.pathPending && agent.remainingDistance < 0.5f)
227
+ GotoNextPoint();
228
+ }
229
+ }
230
+ ```
231
+
232
+ ### Agent Speed Control for Corners
233
+ ```csharp
234
+ using UnityEngine;
235
+ using UnityEngine.AI;
236
+
237
+ public class AgentSpeedController : MonoBehaviour
238
+ {
239
+ NavMeshAgent agent;
240
+ Vector3[] pathCorners = new Vector3[3];
241
+
242
+ [SerializeField] Transform target;
243
+ float maxSpeedStraight;
244
+ [SerializeField] float maxSpeedAtCorner = 0.1f;
245
+ [SerializeField] float distanceThreshold = 0.5f;
246
+
247
+ void OnEnable()
248
+ {
249
+ agent = GetComponent<NavMeshAgent>();
250
+ if (agent != null)
251
+ {
252
+ agent.SetDestination(target.position);
253
+ maxSpeedStraight = agent.speed;
254
+ }
255
+ }
256
+
257
+ void Update()
258
+ {
259
+ if (agent == null) return;
260
+
261
+ int numCorners = agent.path.GetCornersNonAlloc(pathCorners);
262
+ if (numCorners > 2)
263
+ {
264
+ Vector3 first = (pathCorners[1] - pathCorners[0]).normalized;
265
+ Vector3 second = (pathCorners[2] - pathCorners[1]).normalized;
266
+ float speedFactor = Mathf.Clamp01(Vector3.Dot(first, second));
267
+ float distance = Vector3.Distance(pathCorners[0], pathCorners[1]);
268
+ float distanceRatio = Mathf.Clamp01(distance / distanceThreshold);
269
+ float angleMaxSpeed = Mathf.Lerp(maxSpeedAtCorner, maxSpeedStraight, speedFactor);
270
+ agent.speed = Mathf.Lerp(angleMaxSpeed, maxSpeedStraight, distanceRatio);
271
+ }
272
+ else
273
+ {
274
+ agent.speed = maxSpeedStraight;
275
+ }
276
+ }
277
+ }
278
+ ```
279
+
280
+ ### Agent-Driven Animation (Agent Moves, Animation Follows)
281
+ Use NavMeshAgent velocity to drive Animator blend parameters. Simple approach with foot-sliding trade-off.
282
+ ```csharp
283
+ using UnityEngine;
284
+ using UnityEngine.AI;
285
+
286
+ [RequireComponent(typeof(NavMeshAgent))]
287
+ [RequireComponent(typeof(Animator))]
288
+ public class NavAgentAnimator : MonoBehaviour
289
+ {
290
+ Animator anim;
291
+ NavMeshAgent agent;
292
+ Vector2 smoothDeltaPosition;
293
+ Vector2 velocity;
294
+
295
+ void Start()
296
+ {
297
+ anim = GetComponent<Animator>();
298
+ agent = GetComponent<NavMeshAgent>();
299
+ agent.updatePosition = false;
300
+ }
301
+
302
+ void Update()
303
+ {
304
+ Vector3 worldDelta = agent.nextPosition - transform.position;
305
+ float dx = Vector3.Dot(transform.right, worldDelta);
306
+ float dy = Vector3.Dot(transform.forward, worldDelta);
307
+ Vector2 deltaPosition = new Vector2(dx, dy);
308
+
309
+ float smooth = Mathf.Min(1.0f, Time.deltaTime / 0.15f);
310
+ smoothDeltaPosition = Vector2.Lerp(smoothDeltaPosition, deltaPosition, smooth);
311
+
312
+ if (Time.deltaTime > 1e-5f)
313
+ velocity = smoothDeltaPosition / Time.deltaTime;
314
+
315
+ bool shouldMove = velocity.magnitude > 0.5f && agent.remainingDistance > agent.radius;
316
+
317
+ anim.SetBool("move", shouldMove);
318
+ anim.SetFloat("velx", velocity.x);
319
+ anim.SetFloat("vely", velocity.y);
320
+ }
321
+
322
+ void OnAnimatorMove()
323
+ {
324
+ transform.position = agent.nextPosition;
325
+ }
326
+ }
327
+ ```
328
+
329
+ **Animation-Driven Agent** (higher animation quality, agent follows):
330
+ Replace `OnAnimatorMove()` to use animation root position with NavMesh height:
331
+ ```csharp
332
+ void OnAnimatorMove()
333
+ {
334
+ Vector3 position = anim.rootPosition;
335
+ position.y = agent.nextPosition.y;
336
+ transform.position = position;
337
+ }
338
+ ```
339
+ Pull character towards agent if drift exceeds radius (add at end of `Update()`):
340
+ ```csharp
341
+ if (worldDelta.magnitude > agent.radius)
342
+ transform.position = agent.nextPosition - 0.9f * worldDelta;
343
+ ```
344
+
345
+ ### Runtime NavMesh Baking
346
+ ```csharp
347
+ using UnityEngine;
348
+ using Unity.AI.Navigation;
349
+
350
+ public class RuntimeNavMeshBaker : MonoBehaviour
351
+ {
352
+ NavMeshSurface surface;
353
+
354
+ void Start()
355
+ {
356
+ surface = GetComponent<NavMeshSurface>();
357
+ surface.BuildNavMesh();
358
+ }
359
+
360
+ public void RebakeNavMesh()
361
+ {
362
+ surface.UpdateNavMesh(surface.navMeshData);
363
+ }
364
+ }
365
+ ```
366
+
367
+ ### Package installation from a live Editor
368
+
369
+ Editing `Packages/manifest.json` is the route that needs no Editor. When one is connected,
370
+ this is the equivalent C#:
371
+
372
+ ```csharp
373
+ // Fully qualified: this runs through `eval`, which rejects `using` directives.
374
+ var request = UnityEditor.PackageManager.Client.Add("com.unity.ai.navigation@2");
375
+ UnityEngine.Debug.Log("Requested com.unity.ai.navigation@2. Progress shows in the Package Manager window.");
376
+ ```
377
+
378
+
379
+ ## Important API Notes
380
+
381
+ 0. **Namespace:** All navigation components are in `UnityEngine.AI`. The package components (NavMeshSurface, NavMeshLink, NavMeshModifier, NavMeshModifierVolume) are in `Unity.AI.Navigation`.
382
+
383
+ 1. **Setting destination:** Use `agent.destination = position;` or `agent.SetDestination(position);`. Both trigger pathfinding. `SetDestination` returns `bool` indicating if the path request was submitted.
384
+
385
+ 2. **Checking path status:** Use `agent.pathStatus` to check if the path is complete, partial, or invalid:
386
+ ```csharp
387
+ if (agent.pathStatus == NavMeshPathStatus.PathComplete)
388
+ // Full path to destination
389
+ else if (agent.pathStatus == NavMeshPathStatus.PathPartial)
390
+ // Can only reach partway
391
+ else
392
+ // No path at all (PathInvalid)
393
+ ```
394
+
395
+ 3. **Checking remaining distance:** Use `agent.remainingDistance`. IMPORTANT: Check `agent.pathPending` first — `remainingDistance` is unreliable while a path is being calculated:
396
+ ```csharp
397
+ if (!agent.pathPending && agent.remainingDistance < 0.5f)
398
+ // Arrived at destination
399
+ ```
400
+
401
+ 4. **Stopping the agent:** Set `agent.isStopped = true;` to pause movement (retains path). Set `agent.ResetPath();` to clear the path entirely.
402
+
403
+ 5. **Warping the agent:** Use `agent.Warp(position);` to teleport the agent to a new position on the NavMesh. Do NOT set `transform.position` directly — the agent may become desynced from the NavMesh.
404
+
405
+ 6. **NavMesh sampling:** To find the nearest point on the NavMesh:
406
+ ```csharp
407
+ if (NavMesh.SamplePosition(sourcePosition, out NavMeshHit hit, maxDistance, NavMesh.AllAreas))
408
+ {
409
+ Vector3 nearestNavMeshPoint = hit.position;
410
+ }
411
+ ```
412
+
413
+ 7. **Raycast on NavMesh:** To check if there is an unobstructed path between two points on the NavMesh:
414
+ ```csharp
415
+ NavMeshHit hit;
416
+ if (agent.Raycast(targetPosition, out hit))
417
+ {
418
+ // Path is blocked; hit.position is the point where it's blocked
419
+ // hit.distance is the distance to the blocking point
420
+ }
421
+ ```
422
+
423
+ 8. **Path calculation without movement:** Calculate a path without moving the agent:
424
+ ```csharp
425
+ NavMeshPath path = new NavMeshPath();
426
+ if (agent.CalculatePath(targetPosition, path))
427
+ {
428
+ // path.corners contains the waypoints
429
+ // path.status tells if the path is complete, partial, or invalid
430
+ }
431
+ ```
432
+
433
+ 9. **Off-mesh link traversal:** When `autoTraverseOffMeshLink` is disabled, handle manually:
434
+ ```csharp
435
+ if (agent.isOnOffMeshLink)
436
+ {
437
+ OffMeshLinkData data = agent.currentOffMeshLinkData;
438
+ // Animate/teleport from data.startPos to data.endPos
439
+ agent.CompleteOffMeshLink();
440
+ }
441
+ ```
442
+
443
+ 10. **NavMeshSurface baking via script:** The package provides `NavMeshSurface.BuildNavMesh()` for editor and runtime baking, and `NavMeshSurface.UpdateNavMesh(navMeshData)` for incremental updates.
444
+
445
+ 11. **Area cost overrides per agent:**
446
+ ```csharp
447
+ // Make "Water" area (index 3) cost 5x for this specific agent
448
+ agent.SetAreaCost(3, 5.0f);
449
+ ```
450
+
451
+ 12. **CRITICAL: Correct API Names**
452
+
453
+ | WRONG (Hallucinated) | CORRECT |
454
+ |---------------------|---------|
455
+ | `NavMeshAgent.Move(position)` for teleporting | `NavMeshAgent.Warp(position)` |
456
+ | `NavMeshAgent.Stop()` | `NavMeshAgent.isStopped = true;` |
457
+ | `NavMeshAgent.Resume()` | `NavMeshAgent.isStopped = false;` |
458
+ | `NavMeshAgent.target` | `NavMeshAgent.destination` |
459
+ | `NavMesh.Bake()` | `NavMeshSurface.BuildNavMesh()` (package API) |
460
+ | `NavMeshAgent.navMeshPath` | `NavMeshAgent.path` |
461
+ | `NavMeshPath.waypoints` | `NavMeshPath.corners` |
462
+ | `agent.velocity` for setting | `agent.velocity` is read-only for current velocity; use `agent.speed` for max speed |
463
+
464
+
465
+ ## Core Concepts Reference
466
+
467
+ ### NavMesh (Navigation Mesh)
468
+ A mesh Unity generates to approximate walkable areas. Stored as convex polygons with neighbor connectivity. Built by the NavMeshSurface component via voxelization of scene geometry.
469
+
470
+ ### How Pathfinding Works
471
+ 1. Start and destination positions are mapped to the nearest NavMesh polygons.
472
+ 2. A* algorithm searches connected polygons to find the shortest path (a "corridor" of polygons).
473
+ 3. The agent steers towards the next visible corner of the corridor.
474
+ 4. Obstacle avoidance (RVO — reciprocal velocity obstacles) adjusts velocity to prevent collisions with other agents and NavMesh edges.
475
+ 5. A simple dynamic model applies acceleration for smooth movement.
476
+ 6. After movement, the agent position is constrained back onto the NavMesh.
477
+
478
+ ### Global vs. Local Navigation
479
+ - **Global:** Finding the corridor path across the entire NavMesh. Expensive but infrequent.
480
+ - **Local:** Steering towards the next corner, avoiding other agents frame-by-frame. Cheap but continuous.
481
+
482
+ ### Agent Types
483
+ Defined in **Window > AI > Navigation > Agents tab**. Each type specifies:
484
+ - **Radius / Height:** Cylinder dimensions for NavMesh baking clearance.
485
+ - **Step Height:** Max step the agent can climb.
486
+ - **Max Slope:** Steepest walkable incline (degrees).
487
+ - **Drop Height / Jump Distance:** Limits for auto-generated links.
488
+
489
+ A NavMeshSurface bakes for one agent type. Multiple surfaces with different agent types support multiple character sizes.
490
+
491
+ ### Voxels and Bake Quality
492
+ The bake process rasterizes geometry into a 3D voxel grid. Smaller voxels = more accurate NavMesh but slower baking.
493
+ - Default: 3 voxels per agent radius (good for doorways and general use).
494
+ - Big open areas: 1–2 voxels per radius (faster).
495
+ - Tight indoor areas: 4–6 voxels per radius (more detail).
496
+ - More than 8 voxels per radius rarely helps.
497
+
498
+
499
+ ## Component Reference — NavMesh Surface
500
+
501
+ | Property | Description |
502
+ |---|---|
503
+ | **Agent Type** | Which agent type this NavMesh is built for. |
504
+ | **Default Area** | Area type assigned to generated NavMesh (Walkable, Not Walkable, Jump, or custom). |
505
+ | **Generate Links** | Auto-generate jump-across and drop-down links between collected objects. |
506
+ | **Use Geometry** | "Render Meshes" or "Physics Colliders". Colliders let agents walk closer to edges. |
507
+ | **Collect Objects** | "All Game Objects", "Volume", "Current Object Hierarchy", or "NavMeshModifier Component Only". |
508
+ | **Include Layers** | Layer mask filtering which objects contribute to bake. |
509
+
510
+ ### Advanced Settings
511
+ | Property | Description |
512
+ |---|---|
513
+ | **Override Voxel Size** | Override the default voxel size (1/3 agent radius). |
514
+ | **Override Tile Size** | Override default tile size (256 voxels). Smaller tiles = faster carving but more NavMesh fragmentation. Use 64–128 for scenes with many obstacles. |
515
+ | **Minimum Region Area** | Remove small disconnected NavMesh patches below this size. |
516
+ | **Build Height Mesh** | Generate extra data for accurate vertical agent placement (e.g., stairs). Uses more memory. |
517
+
518
+
519
+ ## Component Reference — NavMesh Agent
520
+
521
+ ### Main
522
+ | Property | Description |
523
+ |---|---|
524
+ | **Agent Type** | Must match a NavMeshSurface's agent type to use that NavMesh. |
525
+ | **Base Offset** | Height offset of the collision cylinder relative to the transform pivot. |
526
+
527
+ ### Steering
528
+ | Property | Description |
529
+ |---|---|
530
+ | **Speed** | Max movement speed (units/sec). |
531
+ | **Angular Speed** | Max rotation speed (deg/sec). |
532
+ | **Acceleration** | Max acceleration (units/sec²). |
533
+ | **Stopping Distance** | Agent stops this far from destination. |
534
+ | **Auto Braking** | Slow down near destination. Disable for continuous patrol loops. |
535
+
536
+ ### Obstacle Avoidance
537
+ | Property | Description |
538
+ |---|---|
539
+ | **Radius** | Agent collision radius. |
540
+ | **Height** | Agent height clearance. |
541
+ | **Quality** | Avoidance quality. Reduce for large crowds. "None" = no active avoidance. |
542
+ | **Priority** | 0–99 (lower = higher priority). Agents avoid higher-priority agents. |
543
+
544
+ ### Path Finding
545
+ | Property | Description |
546
+ |---|---|
547
+ | **Auto Traverse OffMesh Link** | Automatically cross NavMesh Links and OffMesh Links. Disable for custom traversal (animation). |
548
+ | **Auto Repath** | Retry pathfinding when reaching end of a partial path. |
549
+ | **Area Mask** | Which area types this agent can traverse. |
550
+
551
+
552
+ ## Component Reference — NavMesh Obstacle
553
+
554
+ | Property | Description |
555
+ |---|---|
556
+ | **Shape** | Box or Capsule. |
557
+ | **Center / Size** | (Box) Obstacle dimensions relative to transform. |
558
+ | **Center / Radius / Height** | (Capsule) Obstacle dimensions relative to transform. |
559
+ | **Carve** | Cut a hole in the NavMesh when stationary. |
560
+ | **Move Threshold** | Distance moved before the carved hole updates. |
561
+ | **Time To Stationary** | Seconds idle before the obstacle is treated as stationary. |
562
+ | **Carve Only Stationary** | Only carve when stopped (best performance for physics objects). |
563
+
564
+ ### When to Use Carving vs. Obstruction
565
+ | Scenario | Carve | Reason |
566
+ |----------|-------|--------|
567
+ | Moving vehicle / player | Off | Use local avoidance; carving is too expensive for moving objects. |
568
+ | Stationary crate / barrel | On | Agents plan paths around; carving recalculates only when moved. |
569
+ | Large slow-moving obstacle (tank) | On, Carve Only Stationary = Off | Carve updates when moved past threshold. |
570
+ | Sparsely scattered small objects | Off | Local avoidance handles these cheaply. |
571
+ | Object that fully blocks a corridor | On | Agents need global pathfinding to find alternate routes. |
572
+
573
+
574
+ ## Component Reference — NavMesh Link
575
+
576
+ | Property | Description |
577
+ |---|---|
578
+ | **Agent Type** | Which agent type can use this link. |
579
+ | **Start Transform / Start Point** | Start position (Transform takes precedence over Point). |
580
+ | **End Transform / End Point** | End position (Transform takes precedence over Point). |
581
+ | **Width** | 0 = point-to-point line; positive = span with width. |
582
+ | **Cost Override** | Override traversal cost (deselect to use area type cost). |
583
+ | **Auto Update Positions** | Update link ends when transforms move. |
584
+ | **Bidirectional** | Allow traversal in both directions. |
585
+ | **Area Type** | Walkable, Not Walkable, Jump, or custom. |
586
+ | **Activated** | Must be enabled for agents to use the link. Disabled = red gizmo. |
587
+
588
+ ### Troubleshooting Links
589
+ - Both ends must be over a NavMesh — check with NavMesh debug visualization.
590
+ - Agent's Area Mask must include the link's Area Type.
591
+ - Activated must be enabled.
592
+ - Agent Type on the link must match the traversing agent's type.
593
+
594
+
595
+ ## Component Reference — NavMesh Modifier
596
+
597
+ | Property | Description |
598
+ |---|---|
599
+ | **Mode** | "Add or Modify Object" (include) or "Remove Object" (exclude). |
600
+ | **Affected Agents** | Which agent types are affected (All, None, or specific). |
601
+ | **Apply to Children** | Cascade to child GameObjects. Another Modifier further down overrides. |
602
+ | **Override Area** | Change the area type for this object. |
603
+ | **Override Generate Links** | Force include/exclude from link generation. |
604
+
605
+ Replaces the legacy "Navigation Static" flag. Works with runtime baking.
606
+
607
+
608
+ ## Component Reference — NavMesh Modifier Volume
609
+
610
+ | Property | Description |
611
+ |---|---|
612
+ | **Size** | Box dimensions (XYZ). |
613
+ | **Center** | Box center relative to GameObject. |
614
+ | **Area Type** | Area type to stamp within this volume. |
615
+ | **Affected Agents** | Which agent types are affected. |
616
+
617
+ When multiple volumes overlap, the highest-index area type wins. **Not Walkable always takes precedence** regardless of index.
618
+
619
+
620
+ ## Navigation Areas and Costs
621
+
622
+ ### Built-In Area Types
623
+ | Area | Index | Description |
624
+ |------|-------|-------------|
625
+ | **Walkable** | 0 | Generic walkable area. |
626
+ | **Not Walkable** | 1 | Blocks navigation; always takes precedence in overlaps. |
627
+ | **Jump** | 2 | Assigned to auto-generated links. |
628
+
629
+ 29 custom area types are available (indices 3–31). Define them in **Window > AI > Navigation > Areas tab**.
630
+
631
+ ### How Cost Works
632
+ Path cost = `distance × area cost`. Higher cost areas are treated as longer distances by A*. All costs must be > 1.0.
633
+
634
+ Example: If "Water" has cost 3.0, a 10-unit path through water costs the same as a 30-unit path on "Walkable" (cost 1.0). The pathfinder prefers the 30-unit dry route only if it exists.
635
+
636
+ ### Per-Agent Cost Override
637
+ ```csharp
638
+ // Make area index 4 ("Mud") cost 5x for this agent
639
+ agent.SetAreaCost(4, 5.0f);
640
+ ```
641
+
642
+ ### Area Mask
643
+ Each agent has an area mask controlling which areas it can use. Set in Inspector or via script:
644
+ ```csharp
645
+ // Allow only Walkable (bit 0) and custom area 3 (bit 3)
646
+ agent.areaMask = (1 << 0) | (1 << 3);
647
+ ```
648
+ Use case: Zombies cannot open doors → uncheck "Door" area in zombie agents' mask.
649
+
650
+
651
+ ## Mixing Components Guide
652
+
653
+ ### NavMeshAgent + Physics
654
+ - Agents do NOT need colliders to avoid each other (navigation handles this).
655
+ - To push physics objects or use triggers: add Collider + Rigidbody with **Is Kinematic = true**.
656
+ - NEVER have both NavMeshAgent and non-kinematic Rigidbody active simultaneously — both try to move the transform, causing undefined behavior.
657
+ - You can use a NavMeshAgent for player movement without physics. Set low avoidance priority (high number) so the player brushes through crowds, and move via `NavMeshAgent.velocity`.
658
+
659
+ ### NavMeshAgent + Animator (Root Motion)
660
+ Both try to move the transform each frame. Pick ONE information flow:
661
+
662
+ **Option A — Animation follows agent (simpler, some foot-sliding):**
663
+ - Let NavMeshAgent control position.
664
+ - Feed `agent.velocity` to Animator parameters for blend tree selection.
665
+
666
+ **Option B — Agent follows animation (higher quality, more complex):**
667
+ - Set `agent.updatePosition = false` and `agent.updateRotation = false`.
668
+ - Use difference between `agent.nextPosition` and `anim.rootPosition` to drive animation.
669
+ - In `OnAnimatorMove()`, use animation root with NavMesh height.
670
+
671
+ ### NavMeshAgent + NavMeshObstacle
672
+ - **Do NOT have both active on the same GameObject.** The agent will try to avoid itself.
673
+ - Use case: Deactivate the agent and activate the obstacle when a character "dies" to make others path around the body.
674
+
675
+ ### NavMeshObstacle + Physics
676
+ - Add NavMeshObstacle to physics objects that agents should be aware of.
677
+ - If the object has a Rigidbody, the obstacle velocity is obtained from it automatically for prediction.
678
+
679
+
680
+ ## Coupling Animation and Navigation
681
+
682
+ ### Setup Requirements
683
+ 1. **Animator Controller** with a 2D blend tree for strafe animations (velx, vely parameters) and an Idle state with a "move" bool parameter.
684
+ 2. **NavMeshAgent** on the same GameObject, with speed matching the animation's maximum velocity.
685
+ 3. The locomotion script (see [Agent-Driven Animation recipe](#agent-driven-animation-agent-moves-animation-follows)).
686
+
687
+ ### Blend Tree Configuration
688
+ - Type: **2D Simple Directional**
689
+ - Compute positions: **Velocity XZ**
690
+ - Parameters: `velx` (float), `vely` (float)
691
+ - Include 7 directional run clips + 1 run-in-place clip (prevents foot-sliding in blends)
692
+ - Idle → Move transition: use `move` bool, disable **Has Exit Time**, set transition duration ~0.1s
693
+
694
+ ### Head Look-At (Optional Quality Improvement)
695
+ Use `Animator.SetLookAtPosition()` in `OnAnimatorIK()` to have the character look toward `agent.steeringTarget` (the next path corner).
696
+
697
+
698
+ ## Troubleshooting Decision Tree
699
+
700
+ ### Agent doesn't move at all
701
+ 1. Is there a baked NavMesh in the scene? → Check for NavMeshSurface with baked data.
702
+ 2. Is the agent positioned on or near the NavMesh? → Use `NavMesh.SamplePosition()` to verify. Warp the agent if needed.
703
+ 3. Is the agent's agent type matching a baked NavMeshSurface agent type?
704
+ 4. Is `agent.isStopped` set to `true`? → Set to `false`.
705
+ 5. Has a destination been set? → Check `agent.hasPath` or `agent.destination`.
706
+ 6. Is the agent enabled and the GameObject active?
707
+
708
+ ### Agent moves but can't reach destination
709
+ 1. Check `agent.pathStatus`:
710
+ - `PathPartial` → Destination is on a disconnected NavMesh region. Add a NavMeshLink or extend the NavMesh.
711
+ - `PathInvalid` → Destination is not on any NavMesh. Verify the destination point is on walkable area.
712
+ 2. Is the destination's area type included in the agent's Area Mask?
713
+ 3. Is a NavMeshObstacle with Carve blocking the only path? → Check for alternate routes or disable the obstacle.
714
+
715
+ ### Agent takes a weird/long path
716
+ 1. Check area costs — high-cost areas make shorter physical paths appear longer to the pathfinder.
717
+ 2. Check NavMesh quality — large polygons next to small ones can cause suboptimal node placement. Reduce voxel size for problem areas.
718
+ 3. Check for unnecessary NavMesh Links that create shortcuts to unintended areas.
719
+
720
+ ### Agent slides through obstacles
721
+ 1. Is the obstacle a NavMeshObstacle? Without this component, navigation ignores it.
722
+ 2. Is Carve enabled? Without carving, the agent uses local avoidance only (limited radius).
723
+ 3. Is the obstacle's shape and size correct? Check Center/Size match the visual mesh.
724
+
725
+ ### Agent vibrates or jitters
726
+ 1. Is both a non-kinematic Rigidbody and NavMeshAgent active? → Set Rigidbody to kinematic.
727
+ 2. Is both a NavMeshAgent and NavMeshObstacle active on the same GameObject? → Disable one.
728
+ 3. Is the agent stuck between two carving obstacles? → Adjust obstacle placement or sizes.
729
+
730
+ ### NavMesh Link not working
731
+ 1. Are both ends connected to the NavMesh? → Enable NavMesh debug visualization in Scene view.
732
+ 2. Is the link's Activated property enabled? (Red gizmo = deactivated.)
733
+ 3. Does the agent's Area Mask include the link's Area Type?
734
+ 4. Does the link's Agent Type match the agent's Agent Type?
735
+ 5. Is `autoTraverseOffMeshLink` enabled on the agent? (Or is custom traversal code handling it?)
736
+
737
+ ### NavMesh bake produces unexpected results
738
+ 1. Check **Use Geometry** — "Render Meshes" includes visual geometry; "Physics Colliders" includes colliders only.
739
+ 2. Check **Collect Objects** — "Current Object Hierarchy" only includes children.
740
+ 3. Check **Include Layers** — objects on excluded layers are ignored.
741
+ 4. Check NavMeshModifiers — an object may be set to "Remove Object".
742
+ 5. Check voxel size — too large skips small geometry details.
743
+ 6. Check agent type settings — radius/height/step height/slope may exclude certain surfaces.
744
+
745
+
746
+ ## Common Mistakes to Avoid
747
+
748
+ ### 1. No NavMesh Baked
749
+ **Problem:** Adding a NavMeshAgent but forgetting to bake a NavMesh. The agent has nowhere to navigate.
750
+ **Solution:** Always ensure at least one NavMeshSurface exists and has been baked.
751
+
752
+ ### 2. Agent Type Mismatch
753
+ **Problem:** NavMeshAgent's agent type doesn't match any NavMeshSurface's agent type. The agent cannot find any NavMesh.
754
+ **Solution:** Ensure the agent type on both the NavMeshSurface and NavMeshAgent match.
755
+
756
+ ### 3. Setting transform.position Directly
757
+ **Problem:** Moving a NavMeshAgent by setting `transform.position` desyncs it from the NavMesh.
758
+ **Solution:** Use `agent.Warp(position)` to teleport, or `agent.destination` / `agent.SetDestination()` for pathfinding.
759
+
760
+ ### 4. NavMeshAgent + NavMeshObstacle on Same GameObject
761
+ **Problem:** The agent tries to avoid itself, causing erratic movement or getting stuck.
762
+ **Solution:** Only have one active at a time. Toggle between them based on state (alive vs. dead).
763
+
764
+ ### 5. Non-Kinematic Rigidbody with NavMeshAgent
765
+ **Problem:** Both the physics engine and the navigation system try to move the transform each frame.
766
+ **Solution:** If you need both, set `Rigidbody.isKinematic = true`.
767
+
768
+ ### 6. Checking remainingDistance While Path Is Pending
769
+ **Problem:** `agent.remainingDistance` returns unreliable values while `agent.pathPending` is true.
770
+ **Solution:** Always guard with `if (!agent.pathPending && agent.remainingDistance < threshold)`.
771
+
772
+ ### 7. Forgetting Auto Braking for Patrol
773
+ **Problem:** Agent slows to a crawl at each patrol waypoint because Auto Braking is on.
774
+ **Solution:** Set `agent.autoBraking = false` for continuous patrol movement.
775
+
776
+ ### 8. Obstacles Without Carve for Static Blockers
777
+ **Problem:** A stationary obstacle blocks a corridor but agents walk into it because only local avoidance is used (no carving).
778
+ **Solution:** Enable **Carve** on stationary obstacles that block paths so the global pathfinder routes around them.
779
+
780
+ ### 9. NavMesh Link Ends Not on NavMesh
781
+ **Problem:** Link gizmo shows disconnected ends (gray lines). Agents can't use the link.
782
+ **Solution:** Position link start and end points directly over baked NavMesh surfaces. Check with NavMesh debug visualization.
783
+
784
+ ### 10. Using Deprecated OffMeshLink Instead of NavMeshLink
785
+ **Problem:** `OffMeshLink` is the legacy component. `NavMeshLink` from the AI Navigation package is the modern replacement with more features (width, transforms, auto-update).
786
+ **Solution:** Always use `NavMeshLink` (from `Unity.AI.Navigation` namespace) for new setups. Migrate existing `OffMeshLink` components.
787
+
788
+ ### 11. Not Re-Baking After Scene Changes
789
+ **Problem:** NavMesh doesn't reflect newly added or moved geometry.
790
+ **Solution:** Re-bake the NavMesh after modifying scene geometry, modifiers, or surface settings. For runtime changes, call `NavMeshSurface.BuildNavMesh()` or `UpdateNavMesh()`.
791
+
792
+ ### 12. Voxel Size Too Large for Narrow Passages
793
+ **Problem:** Doorways or narrow corridors are missing from the NavMesh because the voxel grid is too coarse.
794
+ **Solution:** Reduce voxel size (or use the default 3 voxels per agent radius). For tight spaces, use 4–6 voxels per radius.