unity-navmesh
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseBefore calling any skill in this module: if you are about to call a skill with parameters guessed from its name or description, STOP — read this file (or fetch its schema via) first. If you already have the parameter definitions from recommend/schema, you may proceed straight to dryRun.GET /skills/recommend?includeSchema=true
调用本模块中任何skill之前: 如果你打算仅凭skill名称或描述猜测参数来调用,请停止——先阅读本文档(或通过获取其schema)。如果你已经从推荐/schema中获取了参数定义,可以直接进行dryRun。GET /skills/recommend?includeSchema=true
Triggers
触发场景
- Setting up navigation
- Baking a NavMesh
- Testing agent paths
- Tuning bake parameters
- 搭建导航、烘焙 NavMesh、测试 Agent 路径、调整烘焙参数
- 设置导航
- 烘焙NavMesh
- 测试Agent路径
- 调整烘焙参数
- 搭建导航、烘焙NavMesh、测试Agent路径、调整烘焙参数
NavMesh Skills
NavMesh技能
Bake / clear NavMesh data, calculate paths, sample positions, and configure NavMeshAgent / NavMeshObstacle components.
烘焙/清除NavMesh数据、计算路径、采样位置,以及配置NavMeshAgent/NavMeshObstacle组件。
Operating Mode
运行模式
- Approval:查询类 skill(/
navmesh_calculate_path/navmesh_sample_position,源码标navmesh_get_settings)直接执行;变更类(SkillMode.SemiAuto/navmesh_bake/navmesh_add_agent/navmesh_set_agent/navmesh_add_obstacle/navmesh_set_obstacle,标navmesh_set_area_cost)需用户 grant,grant 后服务端一步执行返结果。SkillMode.FullAuto - Auto / Bypass:所有未被禁列表拦截的 skill 直接执行。
- 本模块含 Delete 类 skill:标记为
navmesh_clear,会被SkillOperation.Delete静态拦截 —— 仅 Bypass 模式或将其加入 Allowlist 才能调用。IsForbiddenInSemi - 同步阻塞主线程;大场景可能很慢,调用前提醒用户。
navmesh_bake
DO NOT (common hallucinations):
- does not exist → use
navmesh_createto generate NavMeshnavmesh_bake - /
navmesh_add_agent_componentdo not exist → usenavmesh_set_agent_speed+navmesh_add_agent(convenience wrappers), ornavmesh_set_agent/component_addfor full controlcomponent_set_property - NavMesh must be re-baked after scene geometry changes
Routing:
- For NavMeshAgent/NavMeshObstacle components → use module
component - For path calculation → (this module)
navmesh_calculate_path
- Approval模式:查询类skill(/
navmesh_calculate_path/navmesh_sample_position,源码标记为navmesh_get_settings)可直接执行;变更类skill(SkillMode.SemiAuto/navmesh_bake/navmesh_add_agent/navmesh_set_agent/navmesh_add_obstacle/navmesh_set_obstacle,标记为navmesh_set_area_cost)需要用户授权(grant),授权后服务端一步执行并返回结果。SkillMode.FullAuto - Auto / Bypass模式:所有未被禁用列表拦截的skill直接执行。
- 本模块包含Delete类skill:被标记为
navmesh_clear,会被SkillOperation.Delete静态拦截——仅在Bypass模式下或将其加入**允许列表(Allowlist)**才能调用。IsForbiddenInSemi - 会同步阻塞主线程;大场景下可能很慢,调用前需提醒用户。
navmesh_bake
请勿犯这些常见错误(幻觉):
- 不存在→请使用
navmesh_create生成NavMeshnavmesh_bake - 不存在/
navmesh_add_agent_component→请使用navmesh_set_agent_speed+navmesh_add_agent(便捷封装),或使用navmesh_set_agent/component_add实现完全控制component_set_property - 场景几何体变更后必须重新烘焙NavMesh
路由说明:
- 针对NavMeshAgent/NavMeshObstacle组件→使用模块
component - 针对路径计算→使用本模块的
navmesh_calculate_path
Skills
技能列表
navmesh_bake
navmesh_bakenavmesh_bake
navmesh_bakeBake the NavMesh (Synchronous). Warning: blocks the Editor, can be slow on large scenes.
Parameters: None.
烘焙NavMesh(同步执行)。警告:会阻塞编辑器,大场景下可能很慢。
参数:无
navmesh_clear
navmesh_clearnavmesh_clear
navmesh_clearClear the NavMesh data.
Parameters: None.
清除NavMesh数据。
参数:无
navmesh_calculate_path
navmesh_calculate_pathnavmesh_calculate_path
navmesh_calculate_pathCalculate a path between two points.
Parameters:
- ,
startX,startY(float): Start position.startZ - ,
endX,endY(float): End position.endZ - (int, optional): NavMesh area mask.
areaMask
Returns:
{ status, valid, distance, cornerCount, corners }- : NavMeshPathStatus string (
status/PathComplete/PathPartial)PathInvalid - :
validonly whentruestatus == "PathComplete" - : total path length (0 for invalid paths)
distance - : number of corner points in
cornerCountcorners - : array of
cornerswaypoints (empty when no path){x, y, z}
计算两点间的路径。
参数:
- ,
startX,startY(float):起始位置。startZ - ,
endX,endY(float):结束位置。endZ - (int,可选):NavMesh区域掩码。
areaMask
返回值:
{ status, valid, distance, cornerCount, corners }- :NavMeshPathStatus字符串(
status/PathComplete/PathPartial)PathInvalid - :仅当
valid时为status == "PathComplete"true - :路径总长度(无效路径为0)
distance - :
cornerCount中的拐点数量corners - :
corners路径点数组(无路径时为空){x, y, z}
navmesh_add_agent
navmesh_add_agentnavmesh_add_agent
navmesh_add_agentAdd NavMeshAgent component to an object.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| name | string | No | null | GameObject name |
| instanceId | int | No | 0 | GameObject instance ID |
| path | string | No | null | GameObject hierarchy path |
Returns:
{ success, gameObject }为对象添加NavMeshAgent组件。
| 参数 | 类型 | 必填 | 默认值 | 描述 |
|---|---|---|---|---|
| name | string | 否 | null | GameObject名称 |
| instanceId | int | 否 | 0 | GameObject实例ID |
| path | string | 否 | null | GameObject层级路径 |
返回值:
{ success, gameObject }navmesh_set_agent
navmesh_set_agentnavmesh_set_agent
navmesh_set_agentSet NavMeshAgent properties (speed, acceleration, radius, height, stoppingDistance).
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| name | string | No | null | GameObject name |
| instanceId | int | No | 0 | GameObject instance ID |
| path | string | No | null | GameObject hierarchy path |
| speed | float | No | null | Agent movement speed |
| acceleration | float | No | null | Agent acceleration |
| angularSpeed | float | No | null | Agent angular speed |
| radius | float | No | null | Agent radius |
| height | float | No | null | Agent height |
| stoppingDistance | float | No | null | Distance to stop before target |
Returns:
{ success, gameObject, speed, radius }设置NavMeshAgent属性(速度、加速度、半径、高度、停止距离)。
| 参数 | 类型 | 必填 | 默认值 | 描述 |
|---|---|---|---|---|
| name | string | 否 | null | GameObject名称 |
| instanceId | int | 否 | 0 | GameObject实例ID |
| path | string | 否 | null | GameObject层级路径 |
| speed | float | 否 | null | Agent移动速度 |
| acceleration | float | 否 | null | Agent加速度 |
| angularSpeed | float | 否 | null | Agent角速度 |
| radius | float | 否 | null | Agent半径 |
| height | float | 否 | null | Agent高度 |
| stoppingDistance | float | 否 | null | 到达目标前的停止距离 |
返回值:
{ success, gameObject, speed, radius }navmesh_add_obstacle
navmesh_add_obstaclenavmesh_add_obstacle
navmesh_add_obstacleAdd NavMeshObstacle component to an object.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| name | string | No | null | GameObject name |
| instanceId | int | No | 0 | GameObject instance ID |
| path | string | No | null | GameObject hierarchy path |
| carve | bool | No | true | Enable carving |
Returns:
{ success, gameObject, carving }为对象添加NavMeshObstacle组件。
| 参数 | 类型 | 必填 | 默认值 | 描述 |
|---|---|---|---|---|
| name | string | 否 | null | GameObject名称 |
| instanceId | int | 否 | 0 | GameObject实例ID |
| path | string | 否 | null | GameObject层级路径 |
| carve | bool | 否 | true | 启用雕刻功能 |
返回值:
{ success, gameObject, carving }navmesh_set_obstacle
navmesh_set_obstaclenavmesh_set_obstacle
navmesh_set_obstacleSet NavMeshObstacle properties (shape, size, carving).
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| name | string | No | null | GameObject name |
| instanceId | int | No | 0 | GameObject instance ID |
| path | string | No | null | GameObject hierarchy path |
| shape | string | No | null | Obstacle shape (e.g. Box, Capsule) |
| sizeX | float | No | null | Obstacle size X |
| sizeY | float | No | null | Obstacle size Y |
| sizeZ | float | No | null | Obstacle size Z |
| carving | bool | No | null | Enable carving |
Returns:
{ success, gameObject, shape, carving }设置NavMeshObstacle属性(形状、大小、雕刻功能)。
| 参数 | 类型 | 必填 | 默认值 | 描述 |
|---|---|---|---|---|
| name | string | 否 | null | GameObject名称 |
| instanceId | int | 否 | 0 | GameObject实例ID |
| path | string | 否 | null | GameObject层级路径 |
| shape | string | 否 | null | 障碍物形状(如Box、Capsule) |
| sizeX | float | 否 | null | 障碍物X轴大小 |
| sizeY | float | 否 | null | 障碍物Y轴大小 |
| sizeZ | float | 否 | null | 障碍物Z轴大小 |
| carving | bool | 否 | null | 启用雕刻功能 |
返回值:
{ success, gameObject, shape, carving }navmesh_sample_position
navmesh_sample_positionnavmesh_sample_position
navmesh_sample_positionFind nearest point on NavMesh.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| x | float | Yes | - | Source position X |
| y | float | Yes | - | Source position Y |
| z | float | Yes | - | Source position Z |
| maxDistance | float | No | 10 | Maximum search distance |
Returns:
{ success, found, point: { x, y, z }, distance }查找NavMesh上最近的点。
| 参数 | 类型 | 必填 | 默认值 | 描述 |
|---|---|---|---|---|
| x | float | 是 | - | 源位置X轴坐标 |
| y | float | 是 | - | 源位置Y轴坐标 |
| z | float | 是 | - | 源位置Z轴坐标 |
| maxDistance | float | 否 | 10 | 最大搜索距离 |
返回值:
{ success, found, point: { x, y, z }, distance }navmesh_set_area_cost
navmesh_set_area_costnavmesh_set_area_cost
navmesh_set_area_costSet area traversal cost.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| areaIndex | int | Yes | - | NavMesh area index |
| cost | float | Yes | - | Traversal cost value |
Returns:
{ success, areaIndex, cost }设置区域遍历成本。
| 参数 | 类型 | 必填 | 默认值 | 描述 |
|---|---|---|---|---|
| areaIndex | int | 是 | - | NavMesh区域索引 |
| cost | float | 是 | - | 遍历成本值 |
返回值:
{ success, areaIndex, cost }navmesh_get_settings
navmesh_get_settingsnavmesh_get_settings
navmesh_get_settingsGet NavMesh build settings.
Parameters: None.
Returns:
{ success, agentRadius, agentHeight, agentSlope, agentClimb }获取NavMesh构建设置。
参数:无
返回值:
{ success, agentRadius, agentHeight, agentSlope, agentClimb }Exact Signatures
精确签名
Exact names, parameters, defaults, and returns are defined by or , not by this file.
GET /skills/schemaunity_skills.get_skill_schema()精确的名称、参数、默认值和返回值由或定义,而非本文档。
GET /skills/schemaunity_skills.get_skill_schema()