Skip to content
Skillpedia
General coding6.6k Β· #13848

unity-navmesh

What it does

This skill shows how to make characters walk around obstacles in Unity using a navigation mesh. It is for developers making enemies chase players or guards patrol.

When to use it

  • βœ“When you want an enemy to chase the player around walls in Unity.
  • βœ“When you need to bake a walkable surface for characters in a Unity scene.
  • βœ“When obstacles like crates or doors should block or change the path during play.

Skill link

https://github.com/gamedev-skills/awesome-gamedev-agent-skills/blob/main/skills/unity/unity-navmesh/SKILL.md

Copy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.

How to use

The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.

Ready-to-paste message

Use this skill to help me: https://github.com/gamedev-skills/awesome-gamedev-agent-skills/blob/main/skills/unity/unity-navmesh/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
Want your AI to find skills like this on its own?Install the free Skillpedia MCP: one line, and it searches 15,000+ skills before each task.Install in 1 minute β†’

Example of what to ask your AI

β€œMake the guard in my Unity level walk to the player's position while avoiding the walls.”

5 new skills a week. 1 minute to read.

How it works

It explains adding a navigation surface component to the level, baking it, and sending agents to a destination, plus using obstacle components for things that move.

Technical content (original SKILL.md)

Original text by the author, straight from GitHub.

Unity NavMesh (AI Navigation)

Give NPCs pathfinding in Unity 6.3 LTS: bake walkable surfaces and move agents around obstacles. Targets Unity 6.3 LTS (6000.3) with the AI Navigation package 2.0 (2.0.16 at last check).

Version trap (Unity 2022+/6): the old built-in Navigation window (Object/Bake tabs, "Navigation Static" flag) is gone. The package's Window β†’ AI β†’ Navigation only holds the Agents and Areas tabs. 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. Agent types (radius, height, step, slope) are defined in Window β†’ AI β†’ Navigation β†’ Agents.
  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.

5. Connect separate mesh pieces with a NavMeshLink (jumps, doors, gaps)

// Two baked surfaces that don't touch (a ledge and the floor below, two platforms across a
// gap) are separate islands β€” an agent can't path between them. Add Component > Navigation >
// NavMesh Link to bridge them: assign Start/End Transforms, set Width (0 = point-to-point),
// and toggle Bidirectional for one-way vs two-way. NavMeshLink lives in Unity.AI.Navigation.
// It replaces the deprecated built-in OffMeshLink (see pitfalls).

Pitfalls

  • **Looking for the Bake tab or the Naviga
FAQ

Why do I need to bake a surface?

Baking tells Unity which areas are walkable, so agents know where they can go.

Does this decide when an enemy should chase?

No. Decision logic is covered by a separate game AI skill, while this one handles movement.

Does it work with the old Navigation window?

The skill notes that the old window is gone, and baking now uses a component from the AI Navigation package.

Details

Original description by the author

Add AI navigation in Unity 6.3 LTS: bake a NavMesh with the AI Navigation package (NavMeshSurface), move agents with NavMeshAgent.SetDestination, and handle dynamic obstacles. Use when setting up pathfinding, making an enemy chase the player, baking navigation, or when the user mentions NavMesh, NavMeshAgent, NavMeshSurface, NavMeshObstacle, or Unity pathfinding.

repo: gamedev-skills/awesome-gamedev-agent-skills

Popularity

GitHub stars
6.6k
Ranking position
#13848
License
Apache-2.0
Updated
10/28/2026

Is this skill useful?

0

Sign in to vote.

Comments

  • …

More skills from this repository

Similar skills