ぼっちプログラマのメモ

UE4とかUE5とかについて書いたり書かなかったり。

UE4メモ : ビヘイビアツリーの「Rotate to face BB entry」タスクについて

「指定されたポイントを巡回」というよくあるAIで、
「次のポイントに移動する前に、そのポイントの方向へ回転する」
ビヘイビアツリーのみで実装したいなぁと思ったわけです。

あ、実行環境は「UE4.10 Preview2」です。


まずは、単純な巡回用ビヘイビアツリー
動かしているのは、Characterアクタを継承したBP。

f:id:pafuhana1213:20151028230644j:plain
f:id:pafuhana1213:20151028230717g:plain

カクカク…もう少し滑らかに回転して欲しい所です…


と、悩んでいる所で見つけたのが、今回取り上げる
「Rotate to face BB entry」タスク

まずは、何も考えずに使ってみます
f:id:pafuhana1213:20151028231053j:plain
f:id:pafuhana1213:20151028231402g:plain

…(#^ω^)


「Rotate to face BB entry」タスクについて調べていると、
以下のスレッドにたどり着きました
How can I fix my BehaviorTree to turn smooth? - UE4 AnswerHub

このスレッドによると、「Rotate to face BB entry」タスクは
実行した瞬間に指定したActorの方に回転する機能を持っているが、
その速度はコントロールできないようです…

The Rotate to Face BB Entry task just requests a character to face given direction and finishes as soon as character does that. This task does not control how fast it's done.

ただ、「Use Controller Rotation Yawを無効」+
「Use Controller Desired Rotationを有効」にすれば、
「RotationRate.Yawの値で回転速度を調整できる」とのことです。

This is the domain of character's properties. If you need non-instant turns you need to make sure your Use Controller Rotation Yaw is disabled and Use Controller Desired Rotation is enabled, then RotationRate.Yaw will control how fast a character can turn/rotate (while moving).

ということで、対象のCharacter継承BPのパラメータを調整

  • Pawnプロパティの、Use Controller Rotation Yawを無効
  • CharacterMovementコンポーネントの、Use Controller Desired Rotationを有効
  • CharacterMovementコンポーネントの、Rotation RateのYawを360→90に

結果
f:id:pafuhana1213:20151028232449g:plain


キタ━━━━(゚∀゚)━━━━!!

以上
(各プロパティについて調べたい所だけど、もう眠気MAXなので後回し)
(「到達してから、次のポイントに移動する前に、周りをキョロキョロする」
  的な仕様の場合は、モーション側で何とかした方がいい気がする)