Communitygithub.com

Unity AI ナビゲーション初期化

Unity AI ナビゲーションシステム(NavMeshサーフェス、NavMeshエージェント、障害物、リンク、モディファイア、エリア、コスト)をセットアップ・構成します。歩行可能なナビゲーションメッシュの作成、経路探索エージェントの追加、巡回ルートの設定、障害物回避とカービングの構成、リンクによるNavMesh間の接続、ナビゲーションとアニメーションの連携、トラブルシューティングに使用します。

Unity AI ナビゲーション初期化 とは?

このスキルは、UnityのAIナビゲーションシステム(`com.unity.ai.navigation`パッケージ)をセットアップ・構成するための包括的なガイドです。ユーザーの意図を「ルーティングロジック」テーブルで解釈し、NavMeshSurfaceのベイク、NavMeshAgentの追加、NavMeshObstacleによる動的障害物設定、NavMeshLinkによる離れたNavMesh領域の接続、NavMeshModifierによるエリアタイプの微調整などを段階的に実行します。このスキルは主にClaude Codeや類似のコード生成エージェント向けに設計されており、エディタが接続されている場合とそうでない場合の両方に対応可能です。また、C#コードを`eval`に渡す際の制約(usingディレクティブの禁止、完全修飾名の必要性)についても明確に説明しています。ワークフローは、パッケージインストール確認、事前調査、情報収集、計画・実行、検証、最終確認の6ステップで構成され、各フェーズで詳細な指示と参照リンクを提供します。エラーを防ぐために、バージョン文字列の正確な指定やアセットインポート後の手動調整が必要な点なども注意喚起しています。

対応~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/unity-technologies/skills/tree/main/skills/initialize-ai-navigation

お気に入りのAIに質問する

このエージェントスキルを事前に読み込んだ状態で新しいチャットを開きます。

ドキュメント

ユーザーのニーズを判断し、ナビゲーション設定をガイドします。コンポーネントの詳細、APIノート、コードレシピ、トラブルシューティングについては、navigation-system.mdを参照してください。

eval に C# を渡す際の注意

eval は ファイルではなくステートメントブロック をコンパイルします。これにより以下の2つの問題が発生し、警告ではなくコンパイルエラーになります。

  • using ディレクティブは使用不可。 コンパイラは using UnityEngine; をリソース破棄ステートメントと解釈し、拒否します(CS0210)。
  • 型は完全修飾名で指定する必要があります。 AssetDatabase や Volume だけでは解決されず(CS0246 / CS0103)、Object は object と曖昧になります(CS0104)。

以下のコードスニペットが、可読性やプロジェクトへの保存のために using を含むファイルとして記述されている場合、eval に渡す前に型を完全修飾名に変更してください。

ルーティングロジック

ユーザーの発言解釈
"ナビゲーションを追加" / "ナビを設定"フルセットアップ:NavMeshSurface + ベイク + NavMeshAgent
"このキャラクターを移動させる"NavMeshAgent を追加、NavMesh が存在することを確認
"経路探索を追加"NavMeshAgent + 移動スクリプト
"エージェントが動かない" / "経路が見つからない"トラブルシューティング — リファレンスの「トラブルシューティング判定ツリー」を参照
"障害物を避ける"カービングまたは回避機能を持つ NavMeshObstacle
"2つのエリアを接続" / "ジャンプして渡る"エリア間の NavMeshLink
"ポイント間をパトロール"NavMeshAgent + パトロールスクリプト
"クリックで移動"NavMeshAgent + レイキャストクリック移動スクリプト
"移動中にキャラクターをアニメーションさせる"Animator と NavMeshAgent の連携
"エージェントのサイズを変える"ナビゲーションウィンドウでエージェントタイプを設定
"エリアとコスト" / "エリアを制限"NavMesh エリアタイプ、モディファイア、エージェントのエリアマスク

ワークフロー

0. パッケージインストールの確認

何よりも先に、com.unity.ai.navigation がインストールされていることを確認してください。不足している場合は、Packages/manifest.json の dependencies に追加します。Unity はエディタがフォーカスを再取得したときに解決します。この操作にエディタ接続は必要ありません。

"com.unity.ai.navigation": "<現在の2.xバージョン>"

バージョン文字列はでっち上げないでください。現在のバージョンは Unity レジストリ(https://packages.unity.com/com.unity.ai.navigation)から読むか、このマニフェスト内の隣接する Unity パッケージがすでに使用しているバージョンをコピーしてください。存在しないバージョンを指定すると、Unity は 静かに 解決に失敗するため、間違った推測は何も起こらなかったように見えます。

インストールが確認されてから先に進んでください。ライブエディタがあり C# を実行できる場合は、navigation-system.md の Client.Add と同等の機能を参照してください。

1. 事前確認:現在のナビゲーション設定の評価

変更を加える前に、既存の設定を検査します。

  1. 既存のナビゲーションコンポーネントを見つけます。エディタが接続されている場合は、ライブシーン内の NavMeshSurface、NavMeshAgent、NavMeshObstacle、NavMeshLink、NavMeshModifier をクエリします(実行中のエディタを操作するには unity-cli スキルを参照)。接続がない場合は、シーンとプレハブファイル内でこれらのコンポーネント名を検索します。
  2. Window > AI > Navigation > Agents タブ で、設定済みのエージェントタイプを確認します。
  3. 変更を提案する前に、検出された すべての ナビゲーションコンポーネントを要約します。

2. 不足情報の収集

コンポーネントを作成する前に、ユーザーが以下を指定していることを確認します:歩行可能なサーフェス、エージェントタイプ/サイズ、エージェントの動作、障害物、リンク、エリア/コスト要件。不明な点があれば質問してください。詳細はリファレンスの「情報収集チェックリスト」を参照してください。

3. 計画と実行

以下の一般的な順序に従ってください。各コンポーネントの詳細な手順は、リファレンスの「コンポーネントセットアップガイド」を参照してください。

  1. NavMesh Surface — 歩行可能なメッシュを作成(ベイク)
  2. NavMesh Agent — 経路探索キャラクターを追加
  3. NavMesh Obstacle — 動的障害物を追加
  4. NavMesh Link — 切断された NavMesh エリアを接続
  5. NavMesh Modifier / Modifier Volume — エリアタイプを微調整
  6. スクリプト — 移動、パトロール、クリック移動、アニメーション連携(リファレンスの「一般的なレシピ」を参照)

4. 検証

セットアップ後、以下を確認します。

  • NavMesh がベイクされ、表示されている(青色のオーバーレイ)
  • NavMeshSurface のエージェントタイプが NavMeshAgent のエージェントタイプと一致している
  • エージェントが目的地への有効な経路を持っている
  • 障害物が正しくカービングまたは妨害している
  • リンクの両端が接続され、Activated が有効になっている
  • エリアマスクが意図した移動を許可している
  • 競合するコンポーネントがない(リファレンスの「コンポーネント混合ガイド」を参照)
  • NavMeshAgent と Rigidbody を併用する場合、Is Kinematic が有効になっている

5. 最終確認

作成または変更した内容を要約します。

  • NavMesh Surfaces:どの GameObject、エージェントタイプ、ジオメトリモード、ベイク状態
  • NavMesh Agent:どの GameObject、速度、停止距離、エリアマスク
  • NavMesh Obstacle:どの GameObject、形状、カービングのオン/オフ
  • NavMesh Link:開始/終了、双方向、エリアタイプ
  • スクリプト:どのスクリプトがどの GameObject にアタッチされたか
  • 手動で必要な手順(ウェイポイントの調整、シーン変更後の再ベイクなど)

Individual skills in this repo

This repo contains 9 individual skills — each has its own dedicated page.

unity-technologies/2d-pixel-perfect

Sets up, diagnoses, and fixes pixel perfect 2D rendering in Unity projects. Use when working on any retro-style or pixel art 2D game.

unity-technologies/audio-setup-mixers

Scans the scene and audio assets to appropriately route Audio Sources into existing Audio Mixer Groups, classifying each source by what it plays. Use when the user asks about cleaning up mixer assignments, routing audio through a mixer, or which group a sound belongs in. Creating mixers and groups, and setting volumes, are not automated — the skill inventories what exists and asks the user to add anything missing.

unity-technologies/build-live-game

Build and operate a live game using Unity Services. Use when the user needs to implement, connect, or debug backend-driven features — battle passes, achievements, player progression, cloud saves, leaderboards, matchmaking, virtual economies, server-authoritative logic, anti-cheat, player accounts and authentication, remote configuration, feature flags, A/B testing, analytics, or cloud resource deployment. Triggers on live-ops, live service, backend, server authority, cloud code, cloud save, remote config, player data, retention, monetization loop, season pass, ranking, multiplayer sessions, lobbies, or any Unity Services integration.

unity-technologies/generate-editor-search-query

Generates Unity Search / Quick Search queries and opens the Unity Search window for read-only Unity Editor asset or scene-object lookup requests. Always use when the user asks to find, search, show, locate, filter, look up, query, or list concrete assets or scene objects in the current project or scene, even if Unity Search is not named. Covers materials, textures, prefabs, scenes, scripts, shaders, GameObjects, components, Lights, Cameras, UI objects, labels, paths, references, selected or named assets, and asset types. Also use when the user explicitly mentions Unity Search, Quick Search, Search window, open Search, or asks what Unity Search query to use. Do not use for general project overview, project structure, folder-purpose summaries, gameplay/system explanations, how-to programming questions, web search, repository text search, build logs, package installation, menu or settings search, modifying results, or non-Unity filesystem search unless the user explicitly asks to use Unity Search.

unity-technologies/implement-in-app-purchases

Implement, configure, and debug Unity In-App Purchases (IAP) — store connection, product catalog, consumable/non-consumable/subscription purchases, two-step pending-confirm flow, receipt validation, entitlement checking, restore transactions, Apple extensions (promotional purchases, Ask-to-Buy, code redemption), and Google Play extensions (subscription upgrade/downgrade), D2C Capabilities(direct to customer), 3rd party payment provider (Stripe/Coda) via Unity IAP/Unity Cloud. Use when the user needs to add, modify, debug, or migrate from native Android/iOS billing, 3rd party packages(RevenueCat/Adapty/Essential Kit/Unipay supported) to IAP. Triggers on microtransactions (MTX), monetization, real-money purchases, store purchases, buying items, support D2C, purchase via Stripe/Coda, migrate from native billing(Google's BillingClient or Apple's StoreKit/SKPaymentQueue/SKProduct)/RevenueCat/Adapty/EssentialKit/Unipay.

unity-technologies/levelplay-unity-integration

Integrates the LevelPlay Mediation SDK via the Ads Mediation UPM package. Use when a developer asks about adding ads to a Unity game, implementing rewarded, interstitial, or banner ads, setting up ad mediation, configuring ad networks, installing or updating the Ads Mediation package, troubleshooting LevelPlay namespace errors, resolving Android gradle or iOS CocoaPods dependency issues for ads, configuring ATT or privacy settings for ad compliance, tracking impression-level revenue (ILRD), initializing the LevelPlay SDK, or setting up ad unit IDs. Also use when a developer wants to monetize their Unity game with ads, asks how to get started with LevelPlay, ads, or mediation, or needs help with any part of the LevelPlay integration workflow including platform-specific setup for iOS or Android. Also use when upgrading the LevelPlay or IronSource SDK version, migrating from deprecated IronSource.Agent APIs, or migrating a game from Unity Ads to LevelPlay.

unity-technologies/localization

Sets up and configures Unity Localization, including locales, String/Asset Tables, CJK font support, and Addressables workflows. Use when the user wants to add languages to a project, translate UI text, support Asian (CJK) languages with TMP fonts, or mentions i18n, l10n, multilingual support, or making a game support multiple languages.

unity-technologies/manage-sprite-atlas

Manage SpriteAtlas using prebuild pipeline with IPreprocessBuildWithReport (DEFAULT approach). Use it to configure master atlases, variant atlases, texture settings, packing settings, and platform-specific configurations. Use when the user asks about creating sprite atlases, optimizing sprites, configuring atlas settings, adding sprites to atlases, creating variant atlases, implementing automated atlas generation, or runtime sprite atlas access. Always use prebuild approach unless user explicitly requests manual authoring.

unity-technologies/migrate-birp-to-urp

Plans, executes, and troubleshoots Unity projects moving from the Built-in Render Pipeline (BiRP/BIRP/Built-in RP) to the Universal Render Pipeline (URP). Use when the user asks to upgrade, convert, switch, or migrate a project, scene, material, or shader to URP/Universal Render Pipeline; fix pink or magenta materials after URP; convert Built-in materials/shaders; move a 2D project to URP 2D; review lighting, quality, post-processing, baked lightmaps, or reflection probes after URP; or diagnose visual problems after a render-pipeline migration.

関連スキル