unitynavmesh

Unity NavMesh–specific skill to help AI agents efficiently perform tasks related to Unity NavMesh.

Installation

Review the source and dependencies with a prompt. A package is available to download.

Install with an AI assistant

Copy the prompt so your assistant can review the pinned revision and dependencies first.

View promptHide prompt
Check whether SkillPI Skill Finder is installed for your current agent. If it is missing, install and enable it using the official instructions at https://github.com/Findskills/skillpi. Then use Skill Finder to locate and install "unitynavmesh" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-163e804796b12227604a27a7a288f132c3a876e3fed64827f30537321b604ef6. Verify the upstream source and version against https://skillhub.cn/skills/user_3c6cb52e/unity-navmesh-skis before installing. If they do not match, stop and report the mismatch. Report the installed path and source version.

Source and setup

skillhub.cn

Setup guidance pending

See the original source for supported tools, dependencies, and permissions.

Installation test pending

Unity NavMesh–specific skill to help AI agents efficiently perform tasks related to Unity NavMesh.

0 Downloads

Introduction source: third_party · user_3c6cb52e · 1.0.0 Reference

SkillPi interpretation

Tasks
Give NPCs pathfinding in Unity 6: bake walkable surfaces and move agents around obstacles. Targets **Unity 6 (6000.0 LTS)** with the **AI Navigation package 2.x**.
Audience
Use when an agent needs to walk/chase/patrol to a target, when baking a navigable surface, adding dynamic blockers (`NavMeshObstacle`), or checking whether a destination is reachable. Use when the project has the AI Navigation package, a `NavMeshSurface` component, or scripts using `UnityEngine.AI.NavMeshAgent`. When *not* to use:** the *decision* logic of when/where to move (FSMs, behaviour trees, steering) → `game-ai` (this skill is the Unity movement/pathing mechanism). Force-driven or kinematic movement that isn't pathfinding → `unity-physics`.
Testing
Not tested

Browse files

Browse files at the source ↗

Original SKILL.md

Open original ↗
Frontmatter
name: Unitynavmesh
slug: unity-navmesh
version: 1.0.0
displayName: Unitynavmesh
description: >
  UnityNavmesh专用技能,帮助AI Agent高效完成相关任务。
summary: "UnityNavmesh专用技能,帮助AI Agent高效完成相关任务。"
license: Apache-2.0
category: 游戏开发
framework:
  - Claude Code
  - Codex
  - Hermes Agent
  - OpenClaw
  - QClaw
  - WorkBuddy
platform: multi-platform
homepage: https://github.com/1991513ccie-png
repository: https://github.com/1991513ccie-png

Unity NavMesh (AI Navigation)

Give NPCs pathfinding in Unity 6: bake walkable surfaces and move agents around obstacles. Targets Unity 6 (6000.0 LTS) with the AI Navigation package 2.x.

Version trap (Unity 2022+/6): the old built-in Navigation window (Object/Bake tabs) is gone. Baking is now component-based via the AI Navigation package (com.unity.ai.navigation): add a NavMeshSurface to your level geometry and click Bake. The runtime NavMeshAgent/NavMesh API stays in built-in UnityEngine.AI.

When to use

  • Use when an agent needs to walk/chase/patrol to a target, when baking a navigable surface, adding dynamic blockers (NavMeshObstacle), or checking whether a destination is reachable.
  • Use when the project has the AI Navigation package, a NavMeshSurface component, or scripts using UnityEngine.AI.NavMeshAgent.

When not to use: the decision logic of when/where to move (FSMs, behaviour trees, steering) → game-ai (this skill is the Unity movement/pathing mechanism). Force-driven or kinematic movement that isn't pathfinding → unity-physics.

Core workflow

  1. Install the AI Navigation package (Package Manager → com.unity.ai.navigation).
  2. Bake a surface: select the static level geometry, Add Component → Navigation → NavMesh Surface, set the agent type/area settings, and click Bake. Re-bake whenever geometry, NavMeshModifiers, or agent settings change.
  3. Add a NavMeshAgent to each moving NPC; its radius/height/speed must match the baked agent type, and it must spawn on the baked mesh.
  4. Drive it from script with SetDestination(targetPos); the agent steers and avoids other agents automatically. Detect arrival with remainingDistance/pathPending.
  5. Handle dynamic blockers with NavMeshObstacle (carving) so closed doors/crates block paths without a full re-bake.
  6. Verify with the AI Navigation overlay (the baked mesh is drawn in the Scene view) and by watching agents path around obstacles to the goal; check NavMeshPath.status for unreachable targets.

Patterns

1. Chase/seek with a NavMeshAgent

using UnityEngine;
using UnityEngine.AI;

[RequireComponent(typeof(NavMeshAgent))]
public class Chaser : MonoBehaviour
{
    [SerializeField] private Transform target;
    private NavMeshAgent _agent;

    private void Awake() => _agent = GetComponent<NavMeshAgent>();

    private void Update()
    {
        if (target) _agent.SetDestination(target.position);   // re-path toward the target
    }

    // Arrived? pathPending guards the first frame before a path exists.
    private bool HasArrived() =>
        !_agent.pathPending && _agent.remainingDistance <= _agent.stoppingDistance;
}

2. Check reachability before committing

using UnityEngine.AI;

public bool CanReach(NavMeshAgent agent, Vector3 destination)
{
    var path = new NavMeshPath();
    agent.CalculatePath(destination, path);
    return path.status == NavMeshPathStatus.PathComplete;   // vs Partial / Invalid
}

3. Bake at runtime (for procedurally built or streamed levels)

using Unity.AI.Navigation;   // the package namespace (NavMeshSurface)

[SerializeField] private NavMeshSurface surface;

// After spawning level geometry, build the navmesh in code.
public void RebuildNav() => surface.BuildNavMesh();

4. Dynamic obstacle that carves the mesh

// Add a NavMeshObstacle (Carve = true) to a door/crate. While present it cuts a hole in the
// navmesh so agents route around it; remove/disable it to reopen the path — no re-bake needed.

Pitfalls

  • Looking for the Navigation window — it no longer exists in Unity 6. Use the AI Navigation package's NavMeshSurface component + Bake.
  • Agent doesn't move / warps to origin — it isn't on the baked mesh, or no surface was baked. Bake the surface and spawn the agent on it (NavMesh.SamplePosition to snap).
  • Agent ignores new geometry — the navmesh is baked; runtime-spawned obstacles need a NavMeshObstacle (carving) or a surface.BuildNavMesh() re-bake.
  • SetDestination every frame is wasteful — for a slow-moving target, re-path on a timer (e.g. every 0.2s) instead of each frame.
  • Agent radius/height mismatch — if the NavMeshAgent's size differs from the baked agent type, it gets stuck in gaps or floats; keep them consistent.
  • Agents jitter against each other — tune avoidancePriority and quality, or use an obstacle for truly static blockers rather than relying on agent avoidance.

References

  • Primary docs: AI Navigation package manual (https://docs.unity3d.com/Packages/com.unity.ai.navigation@2.0/manual/index.html) and ScriptReference/AI.NavMeshAgent, ScriptReference/AI.NavMesh.

Related skills

  • game-ai — engine-agnostic decision-making (FSM, behaviour trees, steering) that uses this.
  • unity-csharp-scripting — the MonoBehaviour structure around the agent.
  • tower-defense / fps-shooter — genres that compose pathfinding with gameplay.

Current listing version

1.0.0

Verify the source revision ↗

Quality assessment

Out of 100 · Assessment report from SkillPi LAB.

Scenario Value92/100

Highlights

  • 专注于 Unity NavMesh 导航功能,面向明确的开发者用户群体,解决 NPC 寻路、表面烘焙、动态障碍物处理等具体任务,实用价值高。
  • 提供了清晰的 Core workflow、Patterns、Pitfalls 和代码示例,内容详实,具有高度的实用价值和明确的场景定位。
Trigger Precision95/100

Highlights

  • description 字段内容完整,位于顶层 frontmatter,清晰描述了 Skill 的用途。
  • 'When to use' 和 'When not to use' 章节进一步明确了触发边界,覆盖了多种使用场景和排除场景,触发词精准完整,边界清晰。
Structure and Standards98/100

Highlights

  • 结构非常清晰,包含 When to use、Core workflow(6 个明确步骤)、Patterns(4 个带代码示例的常见模式)、Pitfalls(6 个常见陷阱)、References 和 Related skills 等完整章节。
  • 提供了端到端的代码示例和最佳实践,frontmatter 完整,单文件未超过 500 行。
Execution Reliability96/100

Highlights

  • 提供了具体的工具使用指导(AI Navigation package)、正确的参数设置(NavMeshSurface, NavMeshAgent)、常见异常处理(如 Agent 不移动、忽略新几何体、抖动等)以及验证方法(AI Navigation overlay, NavMeshPath.status)。
  • 代码示例完整且可直接使用,执行可靠性高。
Evidence Verifiability (mean of the first four)95/100

The arithmetic mean of the first four original scores, rounded to a whole number.

Static text checks

100 / 100 · skillpi-20261123-no-r3-v1

No current rules matched the text.

This score reflects rule matches in the text and is provided for reference before use. It excludes attachments and runtime behavior.

Permissions and checks before use

Automatically summarized from this main document. Matches may be examples or defensive advice; they are not actual permission declarations. Attachments, external dependencies and runtime behavior are not covered.

These common operations were not identified in the main document. This does not mean no permissions or risks exist.

Domains or addresses referenced in the document

These addresses may be documentation links or examples, not an approved network allowlist. Verify actual destinations and outgoing data before use.

  • docs.unity3d.com
  • github.com

These notices grant no permissions. Your host tool must still confirm file changes, secrets, external transfers or costs as needed.

Security rating and access scope

safe · Static evidence review; not a runtime safety guarantee.

Before use, confirm and authorize actual file access, external services and network destinations in your host. This review grants no runtime permissions.