LoginSignup
4
5

More than 5 years have passed since last update.

AIチュートリアル

Last updated at Posted at 2017-03-08

AIチュートリアル

参考URL

ビヘイビアツリーのクイックスタート ガイド

NavMesh コンテンツ サンプル
https://docs.unrealengine.com/latest/JPN/Resources/ContentExamples/NavMesh/index.html

プロジェクトの作成

Blueprint TopDownを使用する

Nav Mesh Bounds Volume

Model -> [Volumes] -> [Nav Mesh Bounds Volume]を画面にドラッグ

Pキーで表示/非表示切り替え

image

基本アセットの作成

image

image

Blueprintsフォルダの作成

BP_AIFollowerControllerを作成する
image

BP_AICharacterを作成する

image

BT_Followerを作成する

image

BB_Followerを作成する
image

BP_AICharacterのセットアップ

BP_AICharacterをダブルクリックで開く

Meshのスケルタルメッシュを[SK_Mannequin]に設定する
image

Transform

項目 X Y Z
Location 0.0 0.0 -85.0
Rotation 0.0 0.0 -90.0
Scale 1.0 1.0 1.0

Animation

項目
Animation Mode Use Animation Blueprint
Anim Class ThirdPerson_AnimBP_C

image

CapsuleComponentの大きさをキャラクターが入る大きさにする

  1. CapsuleComponentを選択する
  2. Shapeの値を変更する
項目
Capsule Half Height 96.0
Capsule Radius 42.0

image

CharacterMovementの設定を変更する

項目
Nav Agent Radius 42.0
Nav Agent Height 192.0

image

Character Movement: Walking

項目
Max Walk Speed 400.0

image

Class Defaultsをクリック

ブループリント エディタのデフォルト タブ

image

AI Controller ClassにBP_AIFollowerControllerを設定する
image

Compile -> Save
image

BB_Followerの設定

BB_Followerをダブルクリックして開く
image

New KeyをクリックしてKey情報を追加する

Entry Name Key Type
TargetToFollow Object
HomeLocation Vector
TargetLocation Vector

image

Save
image

BP_AIFollowerControllerの設定

image

処理の実装

Use Blackboardを追加する
image

Blackboard AssetにBB_Followを設定する
image

ノードを追加する(Get Blackboard,Get Controlled Pawn)
image

image

image

image

image

HomeLocationに値:HomeLocationを設定する
image

VectorValueにGetLocalLocationのReturnをつなげる
Use Blackboardの実行とSet Value as Vectorの実行をつなげる
image

Run Behavior Treeを追加する
image

BTAssetにBT_Followerを選択する
image

Set value as VectorとRun Behavior Treeをつなげる
image

BP_AICharacterを配置する

BP_AICharacterを画面に配置する
image

BT_Followerを編集する

BT_Followerをダブルクリック
image

Composities -> Selectorを選択する
image

Composities -> Sequenceを選択する
image

Composities -> Selectorを選択する
image

image

image

サービスの作成

Services は Composite ノードにアタッチされ、ブランチの実行中は定義された頻度で実行されるノードです。確認してブラックボードを更新するために頻繁に使用されます。他のビヘイビアツリー システムの通常の Parallel ノードの代わりになります。

BT_Followerを開いた状態で、[New Service]をクリックする
BTService_Bluprint Base Newというファイルが出来るので、名前をBTService_AgroCheckに設定する
image

変数を設定する

変数名
DesiredObjectTypes EObjectTypeQuery(配列)
MyLocation Vector
AI_CON_Ref BP_AIFollowerController(Reference)
TargetToFollow BlackboardKeySelector
TargetLocation BlackboardKeySelector

image

DesiredObjectTypesの初期値を設定する
1. 配列を1つ追加する
2. Pawnを設定する
image

image

image

image

タスクの作成

image

変数の追加

変数名
AI_CON_Ref BP_AIFollowerController(Reference)
TargetToFollow BlackboardKeySelector

image

処理の実装

image

デコレーターの作成

image

変数の追加

変数名
AI_CON_Ref BP_AIFollowerController(Reference)
AcceptableDistance Float
TargetToFollow BlackboardKeySelector

image

関数の追加と実装

Function [Override] -> [Perform Condition Check]を選択する
image

処理の実装
image

ビヘイビアツリーのビルド

サービスを追加

image

Default

項目
Target to Follow TargetToFollow
Target Location TargetLocation

Service

項目
Interval 0.5
Random Devlation 0.0

image

タスクを追加する

BTTask Rapid Move Toを追加
image

Move Toを追加
image

Waitを追加
image

Move Toを追加
image

追加したタスクを接続する

image

Move ToのBlackboardを選択する
左側: Target Location
右側: Home Location
image

Waitの詳細を設定する

Wait

項目
Wait Time 0.25

image

BTTask_RapidMoveToの詳細を設定する

Default

項目
Target to Follow TargetToFollow

image

デコレーターを追加する

Selectorのデコレーターを追加する

Blackboardを追加する
image

BTDecorator Close Enoughを追加する
image

Selector:Blackboardの詳細を設定する

Default

項目
Observer Aborts Both

image

Selector:BTDecorator Close Enoughの詳細を設定する

項目
Acceptable Distance 100
Target to Follow TargetToFollow

image

Sequenceのデコレーターを追加する

Blackboardを追加する

image

Is at Locationを追加する
image

Blackboardを追加する
image

Blackboard(上)の詳細を設定する

Brackboard

項目
Key Query Is Not Set

image

Blackboard(下)の詳細を設定する
Brackboard

項目
Blackboard Key HomeLocation

image

Is At Locationの詳細を設定する

Condition

項目
Inverse Condition チェック

Blackboard

項目
Blackboard Key HomeLocation

image

4
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
5