initialize-ai-navigation
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseDetermine what the user needs and guide them through navigation setup. See navigation-system.md for expanded component details, API notes, code recipes, and troubleshooting.
确定用户需求并引导他们完成导航设置。如需了解组件详细信息、API说明、代码示例及故障排查内容,请查看navigation-system.md。
Passing C# to eval
eval将C#代码传入eval
evaleval- No directives. The compiler reads
usingas a resource-disposal statement and rejects it (using UnityEngine;).CS0210 - Types must be fully qualified. A bare or
AssetDatabasedoes not resolve (Volume/CS0246), and a bareCS0103is ambiguous withObject(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 .
evaleval- 不支持指令:编译器会将
using视为资源释放语句并拒绝执行(错误码using UnityEngine;)。CS0210 - 类型必须完全限定:直接使用或
AssetDatabase无法解析(错误码Volume/CS0246),直接使用CS0103会与Object产生歧义(错误码object)。CS0104
如果下方的代码片段是以文件形式编写的——为了可读性包含using指令,或是需要保存到项目中——在传入前请先对类型进行完全限定。
evalRouting 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 |
| 用户表述 | 解读 |
|---|---|
| "add navigation" / "set up nav" | 完整设置:NavMeshSurface + 烘焙 + NavMeshAgent |
| "make this character navigate" | 添加NavMeshAgent,确保NavMesh已存在 |
| "add pathfinding" | NavMeshAgent + 移动脚本 |
| "agent won't move" / "path not found" | 故障排查——请参考文档中的故障排查决策树 |
| "avoid obstacles" | 启用雕刻或避障功能的NavMeshObstacle |
| "connect two areas" / "jump across" | 连接两个区域的NavMeshLink |
| "patrol between points" | NavMeshAgent + 巡逻脚本 |
| "click to move" | NavMeshAgent + 射线点击移动脚本 |
| "animate the character while navigating" | 将Animator与NavMeshAgent关联 |
| "different agent sizes" | 在Navigation窗口中配置Agent类型 |
| "areas and costs" / "restrict areas" | NavMesh区域类型、修改器及Agent区域遮罩 |
Workflow
工作流程
0. Package Installation Check
0. 包安装检查
Before doing anything else, verify that is installed. If it's missing,
add it to under — Unity resolves it when the Editor next
regains focus, and this needs no Editor connection:
com.unity.ai.navigationPackages/manifest.jsondependenciesjson
"com.unity.ai.navigation": "<current 2.x version>"Don't invent the version string. Read the current one from the Unity registry —
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.
https://packages.unity.com/com.unity.ai.navigationProceed only once it's confirmed installed. If you have a live Editor to run C# in, see
navigation-system.md for the equivalent.
Client.Add在进行任何操作之前,请确认包已安装。如果缺失,请将其添加到的下——Unity会在编辑器重新获得焦点时自动解析,此操作无需编辑器联网:
com.unity.ai.navigationPackages/manifest.jsondependenciesjson
"com.unity.ai.navigation": "<current 2.x version>"请勿自行编写版本字符串。请从Unity注册表读取当前版本——列出了所有已发布的版本——或者复制manifest中相邻Unity包已使用的版本。不存在的版本会导致Unity静默解析失败,错误的版本看起来就像没有任何操作发生。
https://packages.unity.com/com.unity.ai.navigation仅在确认包已安装后再继续。如果可以在运行的编辑器中执行C#代码,请查看navigation-system.md了解对应的用法。
Client.Add1. Pre-Flight: Assess Current Navigation Setup
1. 预检:评估当前导航设置
Before making changes, inspect what already exists:
- Find the existing navigation components. With a connected Editor, query the live scene for
,
NavMeshSurface,NavMeshAgent,NavMeshObstacleandNavMeshLink— see theNavMeshModifierskill for driving a running Editor. Without one, search the scene and prefab files for those component names.unity-cli - Check configured agent types via Window > AI > Navigation > Agents tab.
- Summarize ALL detected navigation components before proposing changes.
在进行更改之前,请检查已有的设置:
- 查找现有的导航组件。如果已连接编辑器,请在实时场景中查询、
NavMeshSurface、NavMeshAgent、NavMeshObstacle和NavMeshLink——请参考NavMeshModifier技能来操作运行中的编辑器。如果未连接编辑器,请在场景文件和预制件文件中搜索这些组件名称。unity-cli - 通过Window > AI > Navigation > Agents标签页检查已配置的Agent类型。
- 在提出更改建议之前,总结所有检测到的导航组件。
2. Gather Missing Information
2. 收集缺失信息
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.
在创建组件之前,请确保用户已指定:可行走表面、Agent类型/尺寸、Agent行为、障碍物、链接以及区域/成本要求。如有不明确之处,请询问用户。详细信息请参考文档中的信息收集清单。
3. Planning & Execution
3. 规划与执行
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)
请遵循以下大致顺序。每个组件的详细分步说明请参考文档中的组件设置指南:
- NavMesh Surface——创建可行走网格(进行烘焙)
- NavMesh Agent——添加寻路角色
- NavMesh Obstacle——添加动态障碍物
- NavMesh Link——连接断开的NavMesh区域
- NavMesh Modifier / Modifier Volume——微调区域类型
- 脚本——移动、巡逻、点击移动、动画关联(请参考文档中的常用示例)
4. Validation
4. 验证
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
设置完成后,请确认:
- NavMesh已烘焙并可见(蓝色覆盖层)
- NavMeshSurface的Agent类型与NavMeshAgent的Agent类型匹配
- Agent有到达目标点的有效路径
- 障碍物正确进行雕刻或阻挡
- 链接两端均已连接且已启用Activated
- 区域遮罩允许预期的移动
- 无冲突组件(请参考文档中的组件混用指南)
- 如果将Rigidbody与NavMeshAgent一起使用,需启用Is Kinematic
5. Final Confirmation
5. 最终确认
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.)
总结已创建或更改的内容:
- NavMesh Surfaces:所属GameObject、Agent类型、几何模式、烘焙状态
- NavMesh Agent(s):所属GameObject、速度、停止距离、区域遮罩
- NavMesh Obstacle(s):所属GameObject、形状、是否启用雕刻
- NavMesh Link(s):起点/终点、是否双向、区域类型
- 脚本:已附加到哪些GameObject的哪些脚本
- 任何需要手动完成的步骤(调整路点、场景更改后重新烘焙等)