Skip to content
OpenAgentSkill
Browsing is open · Catalog captured 2026-11-21 · Automatic updates and account services are paused.
Design & UI

unity-ai-navigation

Unity 6 AI and navigation guide. Use when working with NavMesh, pathfinding, NavMeshAgent, NavMeshSurface, NavMeshObstacle, off-mesh links, or Unity Sentis (ML model inference). Covers AI navigation package, runtime NavMesh baking, and common AI patterns like state machines and behavior trees. Based on Unity 6.3 LTS documentation.

Nice-Wolf-Studio · Static checks on file

Installation

Read the source and dependencies before running a command. Copying does not install or execute anything.

npx skills add Nice-Wolf-Studio/unity-claude-skills --skill unity-ai-navigation

About this skill


name: unity-ai-navigation description: > Unity 6 AI and navigation guide. Use when working with NavMesh, pathfinding, NavMeshAgent, NavMeshSurface, NavMeshObstacle, off-mesh links, or Unity Sentis (ML model inference). Covers AI navigation package, runtime NavMesh baking, and common AI patterns like state machines and behavior trees. Based on Unity 6.3 LTS documentation.

Unity 6 AI and Navigation Guide

Source: Unity 6.3 LTS Documentation (6000.3)

AI Navigation Overview

Package: com.unity.ai.navigation (v2.0.11 for Unity 6000.3)

The AI Navigation package is a high-level component system that enables NavMesh-based navigation and pathfinding. It supports runtime and edit-time NavMesh construction, dynamic obstacle management, and link systems for specialized actions (jumping, doors).

Core Components

ComponentPurpose
NavMeshSurfaceDefines and builds NavMesh for a specific agent type
NavMeshAgentCharacter pathfinding and movement
NavMeshObstacleDynamic obstacle avoidance
NavMeshModifierAffects NavMesh generation based on transform hierarchy
NavMeshModifierVolumeAffects NavMesh generation based on volume
NavMeshLinkConnects same or different NavMesh surfaces

NavMesh Setup

Baking a NavMesh

  1. Add a NavMeshSurface component to a GameObject
  2. Configure the Agent Type (determines which agents can use this surface)
  3. Set Use Geometry to Render Meshes or Physics Colliders
  4. Configure Collect Objects mode (All, Volume, Current Hierarchy, NavMeshModifier only)
  5. Click Bake or call BuildNavMesh() at runtime

NavMeshSurface Properties

PropertyDescription
Agent TypeWhich NavMesh Agent configuration can use this surface
Default AreaWalkable (default), Not Walkable, Jump, plus 29 custom types
Use GeometryRender Meshes or Physics Colliders (colliders allow closer edge navigation)
Generate LinksAuto-creates connections between collected GameObjects during bake
Collect ObjectsAll GameObjects, Volume, Current Hierarchy, NavMeshModifier only
Include LayersFilters GameObjects by layer (default: Everything)

Advanced Baking Parameters

ParameterDescription
Override Voxel SizePrecision (default: 3 voxels per agent radius)
Override Tile SizeTile dimensions (default: 256 voxels); smaller = better carving
Minimum Region AreaRemoves disconnected mesh segments below threshold
Build Height MeshGenerates elevation data for character placement

The system excludes GameObjects with NavMeshAgent or NavMeshObstacle during baking.

Runtime NavMesh Baking

using UnityEngine;
using Unity.AI.Navigation;

public class RuntimeNavMeshBaker : MonoBehaviour
{
    NavMeshSurface surface;

    void Start()
    {
        surface = GetComponent<NavMeshSurface>();
        surface.BuildNavMesh();
    }

    public void RebakeNavMesh()
    {
        surface.UpdateNavMesh(surface.navMeshData);
    }
}

NavMeshAgent

The NavMeshAgent component handles both pathfinding and movement control.

Add via: Add Component > Navigation > NavMesh Agent

Basic Movement

using UnityEngine;
using UnityEngine.AI;

public class MoveTo : MonoBehaviour
{
    public Transform goal;

    void Start()
    {
        NavMeshAgent agent = GetComponent<NavMeshAgent>();
        agent.destination = goal.position;
    }
}

Agent Properties

Steering: Speed, Angular Speed, Acceleration, Stopping Distance, Auto Braking

Obstacle Avoidance: Radius, Height, Quality (None to High), Priority (0-99; lower = higher)

Agents avoid others of higher priority and ignore those of lower priority.

Pathfinding: Auto Traverse OffMesh Link, Auto Repath, Area Mask

Agent Scripting Patterns

using UnityEngine;
using UnityEngine.AI;

public class AIController : MonoBehaviour
{
    NavMeshAgent agent;

    void Start() { agent = GetComponent<NavMeshAgent>(); }

    public void MoveToTarget(Vector3 target) { agent.SetDestination(target); }

    bool HasReachedDestination()
    {
        if (!agent.pathPending
            && agent.remainingDistance <= agent.stoppingDistance
            && (!agent.hasPath || agent.velocity.sqrMagnitude == 0f))
            return true;
        return false;
    }

    public void StopMoving() { agent.isStopped = true; }
    public void ResumeMoving() { agent.isStopped = false; }
    public void WarpTo(Vector3 position) { agent.Warp(position); }
}

Partial Paths

When a destination is unreachable, the agent generates a partial path to the nearest reachable location:

if (agent.pathStatus == NavMeshPathStatus.PathPartial)
    Debug.Log("Destination unreachable, using partial path");
else if (agent.pathStatus == NavMeshPathStatus.PathInvalid)
    Debug.Log("No valid path found");

NavMeshObstacle

Defines dynamic obstacles that agents avoid. Add via: Add Component > Navigation > NavMesh Obstacle

Shapes: Box (Center + Size) or Capsule (Center + Radius + Height)

Carving

PropertyDescription
Move ThresholdDistance triggering update for moving obstacles
Time To StationarySeconds before classified as stationary
Carve Only StationaryOnly carve when not moving
  • Carved: Dynamically modify NavMesh topology (barrels, crates, doors)
  • Non-carved: Exclusion zones without mesh modification (moving characters)
using UnityEngine;
using UnityEngine.AI;

public class DynamicObstacle : MonoBehaviour
{
    NavMeshObstacle obstacle;

    void Start()
    {
        obstacle = GetComponent<NavMeshObstacle>();
        obstacle.carving = true;
        obstacle.carveOnlyStationary = true;
    }

    public void SetBlocking(bool blocking) { obstacle.enabled = blocking; }
}

Off-Mesh Links (NavMeshLink)

Connects

Read the complete source ↗