ナビゲーション メッシュの修正をするための準備ガイド

このガイドでは、ナビゲーション メッシュの変更について学ぶために必要な予備的な手順を説明します。

概要

このドキュメントでは、ナビゲーション メッシュのさまざまな変更方法について説明する準備作業として、レベルと AI エージェントを作成する手順を説明します。

なお、完全なサンプル プロジェクト をダウンロードすることもできます。サンプル プロジェクトには、このガイドで取り上げるすべてのマテリアルが含まれています。

目的

  • シンプルなレベルを作成し、レベル内にナビメッシュ バウンズ ボリューム アクタを配置してナビゲーションを追加する。

  • ナビゲーション システムを使用してレベル内を歩き回るように ThirdPersonCharacter ブループリントを変更する。

1 - 必要な設定

  1. メニューの [New Project Categories (新規プロジェクトカテゴリ)] セクションで [Games (ゲーム)] > [Third Person (サードパーソン)] の順に選択します。

    Select the Games category and select Games and the Third Person template

  2. [Blueprint (ブループリント)][No Starter Content (スターター コンテンツなし)] オプションを選択し、[Create] をクリックします。

    Select Blueprint and No Starter Content and click Create

このセクションの結果

新しいサードパーソンプロジェクトが作成され、ナビゲーション メッシュを使用して基本的なレベルを構築する準備が整いました。

2 - テスト レベルを作成する

  1. メニューバーで [File] > [New File...] の順にクリックします。

    Create a new Level

  2. [Basic] レベルを選択して [Create] をクリックします。

    Select the Basic Level and click Create

  3. アウトライナ[Floor] スタティック メッシュ アクタを選択し、[Details (詳細)] パネルで [Scale (拡大・縮小)] を X = 10、Y = 10、Z = 1 に設定します。

    Select the Floor Static Mesh Actor in the World Outliner

    Set the Scale to X = 10, Y = 10, Z = 1

  4. コンテンツ ブラウザ「LevelPrototyping」>「Meshes」 の順に移動し、[TemplateFloor] スタティック メッシュをレベルにドラッグします。

    Drag the Template Floor Static Mesh into the Level

  5. [Place Actors (アクタを配置)] パネルに移動し、「Nav Mesh Bounds Volume」を検索します。これをレベルにドラッグして、Floor メッシュ上に配置します。

    Drag the Nav Mesh Bounds Volume to the Level

  6. NavMeshBoundsVolume を選択して、フロア全体をカバーするために [Details] パネルで [Scale] を X = 20, Y = 20, Z = 5 に設定します。Unreal Engine はデフォルトでナビゲーションバウンド内に自動的にナビゲーションを生成します。ナビメッシュ アクタ RecastNavMesh-Default もレベルに追加する必要があります。P キーを押して、レベルでナビゲーション メッシュを視覚化します。

    ナビゲーションが生成されない場合は、[Project Settings] > [Navigation System] を選択して [Auto Create Navigation Data] チェックボックスを有効にします。

    Set the Scale to X = 20, Y = 20, Z = 5

    The Navigation Mesh now covers the entire floor

  7. [Place Actors] パネルに移動し、 [Shapes] カテゴリで [Cube (キューブ)] スタティック メッシュ アクタをレベルにドラッグします。

    Drag the Cube Static Mesh Actor into your Level

  8. その キューブ を選択した状態で [Details] パネルに移動して、 [Scale] を X = 1、Y = 1、Z = 5 に設定します。

    Set the Scale to X = 1, Y = 1, Z = 5

    The Cube is now rescaled

  9. Cubes をあと 3 つレベルにドラッグして、上のようにスケーリングします。それらを床付近に配置して、以下のように柱を 4 本作成します。

    Drag three more Cubes into the level and scale them like the one above

  10. 次に真ん中に階段とプラットフォームを追加します。コンテンツ ドロワー「サードパーソン」>「メッシュ」 の順に移動し、Linear_Stair_StaticMesh をレベルにドラッグします。

    Add a stair and a platform in the middle

  11. 階段を選択した状態で [Details] パネルに移動して、 [Scale] を X = 1.5、Y = 1、Z = 1.3 に設定します。

    Set the Scale to X = 1.5, Y = 1, Z = 1.3

  12. 階段を選択して、Alt キーを長押ししてメッシュをドラッグして複製します。

    Duplicate the stairs mesh

  13. [Place Actors] パネルに移動し、 [Shapes] カテゴリで [Cube (キューブ)] スタティック メッシュ アクタをレベルにドラッグします。[Details] パネルで [Scale] を [X = 14, Y = 4, Z = 0.1] に設定します。以下のように、アクタを階段の端に配置してプラットフォームを作成します。

    Drag a Cube Static Mesh Actor into your Level and set the scale to X = 14, Y = 4, Z = 0.1

  14. [Place Actors] パネルに移動し、 [Basic (基本)] カテゴリで [Sphere (球)] スタティック メッシュ アクタをレベルにドラッグします。

    Drag a Sphere Static Mesh Actor into your Level

  15. 球体 を選択した状態で[Details (詳細)] パネルに行き、[Collision] セクションで [Collision Presets][No Collision] に設定します。

    Set the Collision Presets to No Collision

  16. 最後に、球体を複製して、以下のようにそれらをレベルの周りに配置します。

    Duplicate the spheres and place them around your Level

このセクションの結果

このセクションでは、シンプルなレベルを作成してナビメッシュ バウンズボリュームを追加します。さらに、エージェントのターゲット アクタの役割を果たす 5 つの球を追加します。

3 - エージェントを作成する

このセクションでは、ターゲット アクタのリストの間を移動する AI Agent を作成します。

  1. コンテンツ ドロワー[New Folder (新規フォルダ)] を選択して新規フォルダを作成します。このフォルダに「NavigationSystem」という名前を付けます

  2. コンテンツ ドロワー で、「ThirdPerson」>「Blueprints」 の順に移動し、[BP_ThirdPersonCharacter] ブループリントを選択します。これを「NavigationSystem」フォルダにドラッグし、 [Copy Here (ここにコピー)] オプションを選択します。

    Copy the Third Person Character Blueprint to the Navigation System folder

  3. NavigationSystem」フォルダに移動して、ブループリントの名前を「BP_NPC_ModNavMesh」に変更します。ブループリントをダブルクリックしてブループリント エディタ内で開き、イベント グラフ に移動します。入力ノードをすべて選択して削除します。

  4. イベント グラフ を右クリックし、「Add Custom Event」を検索、選択します。イベントに「MoveNPC」という名前を付けます。

    Right click the Event Graph, then search for and select Add Custom Event. Name it Move NPC

  5. [My Blueprint (マイ ブループリント)] パネルに移動し [Variables (変数)] の隣の 追加 (+) ボタン をクリックして新しい変数を作成します。変数の名前を「TargetList」にします。

    Create a new variable and name it Target List

  6. [Details] パネルを開き、Variable Type の横にあるドロップダウンをクリックします。「Actor」を検索して、[Object Reference (オブジェクト参照)] を選択します。

    Set the variable type to Actor Object Reference

  7. アクタ選択の横にある 青い球 のアイコンをクリックして以下のように [Array] オプションをクリックします。[Instance Editable] チェックボックスをクリックして有効にします。

    Click the blue sphere icon next to Actor selection and click the Array option

    Click the Instance Editable checkbox to enable it

  8. TargetList 変数を イベント グラフ にドラッグし、オプション Get TargetList を選択します。

  9. TargetList ノードからドラッグして、「Last Index」を検索、選択します。

    Drag from the TargetList node, then search for and select Last Index

  10. TargetList ノードからドラッグし、「Get (a copy)」を検索して選択します。

    Drag from the TargetList node and search for and select Get a copy

  11. Get ノードの 緑色 のピンからドラッグし、「Random Integer in Range」を検索、選択します。以下のように、Last Index ノードの 緑の ピンを Random Integer in Range ノードの Max ピンに接続します。

    Drag from the green pin of the Get node, then search for and select Random Integer in Range

    Connect the green pin of the Last Index node to the Max pin of the Random Integer in Range node

  12. Get ノードからドラッグして、Promote to variable を検索して選択します。変数 CurrentTarget に名前をつけて、MoveNPC ノードに接続します。

    Drag from the Get node, then search for and select Promote to variable

    Name the variable Current Target and connect it to the Move NPC node

  13. CurrentTarget ノードからドラッグして、「Is Valid」を検索、選択します。IsValid マクロを Set CurrentTarget ノードに接続します。

    Drag from the CurrentTarget node, then search for and select Is Valid

    Connect the IsValid macro node to the Set CurrentTarget node

  14. CurrentTarget 変数を イベント グラフ にドラッグし、Get Current Target を選択します。CurrentTarget ノードからドラッグして、「Get Actor Location」を検索、選択します。

    Drag from the CurrentTarget node, then search for and select Get Actor Location

  15. GetActorLocation ノードの Return Value からドラッグし、「Get Random Reachable Point In Radius」を検索、選択します。Radius の値を 100 を設定します。

    Drag from the Return Value of the GetActorLocation node, then search for and select Get Random Reachable Point In Radius

    Set the Radius value to 100

  16. GetRandomReachablePointInRadius ノードの Random Location ピンからドラッグして Promote to variable を選択します。変数の名前を「RandomLocation」にします。以下のように、RandomLocation ノードを IsValid ノードに接続します。

    Drag from the Random Location pin of the GetRandomReachablePointInRadius node and select Promote to variable. Name the variable Random Location

    Connect the RandomLocation node to the IsValid node

  17. RandomLocation ノードからドラッグして、「AI MoveTo」を検索、選択します。

    Drag from the Random Location node, then search for and select AI MoveTo

  18. AI MoveTo ノードの Pawn ピンをドラッグして、「Get a reference to self」を検索、選択します。RandomLocation ノードの 黄色 ピン を AI MoveTo ノードの Destination ピンに接続します。最後に、AI MoveTo ノードの Acceptance Radius を以下のように 50 に設定します。

    Drag from the Pawn pin of the AI MoveTo node, then search for and select Get a reference to self

    Connect the yellow pin of the Random Location node to the Destination pin of the AI MoveTo node

  19. AI Move To ノードの On Success ピンをドラッグして、「Delay」を検索、選択します。以下のように、このノードの [Duration (期間)]4 に設定します。Delay ノードの Completed ピンをドラッグして、「MoveNPC」を検索、選択します。

    Drag from the On Success pin of the AI Move To node, then search for and select Delay. Set the Duration to 4. Drag from the Delay node and add a Move NPC node

  20. 上記の手順を繰り返して、AI Move To ノードの On Fail ピンにノードを追加します。Delay ノードの Duration を 0.1 に設定します。

    Repeat the steps above to add the nodes to the On Fail pin of the AI Move To node. Set the Duration of the Delay node to 0.1

  21. イベント グラフ を右クリックし、「Event Begin Play」を検索して選択します。Event Begin Play ノードからドラッグして、「MoveNPC」を検索、選択します。

    Right-click the Event Graph, then search for and select Event Begin Play

    Drag from the Event Begin Play node, then search for and select Move NPC

  22. ブループリントを コンパイル して、保存 します。

  23. BP_NPC_ModNavMesh ブループリントをレベルにドラッグして、 [Details] パネルで [Target List] を見つけて、Add (+) ボタン をクリックして新しいターゲット アクタを追加します。

    Drag your BP_NPC_ModNavMesh Blueprint into your Level

    In the Details panel find the Target List and click the Add button to add a new target Actor

  24. ドロップダウンをクリックして、すでに作成した Sphere アクタを検索して選択します。

    Click the dropdown, then search for and select the Sphere Actor

  25. 上記の手順を繰り返して残りの 4 つの Sphere アクタを追加します。

    Repeat the step above to add the remaining four Sphere Actors

  26. Simulate をクリックしてエージェントがレベルの目標間を移動するのを確認します。

    Click Simulate to see your Agent roam between goals in your Level

このセクションの結果

このセクションでは、ターゲット アクタのリストの間を移動するエージェントを作成しました。これで、ナビゲーション システムの変更 についての学習に進むことができます。

タグ
Unreal Engine のドキュメントを改善するために協力をお願いします!どのような改善を望んでいるかご意見をお聞かせください。
調査に参加する
キャンセル