🎬
[Unreal Engine 5] アニメーションの合成と切り替え
やりたいこと
- 移動中、上半身では攻撃アニメーション、下半身では歩行アニメーションを再生する
- 歩いていないときは全身で攻撃アニメーションを再生する
- 必殺技みたいなものを出すときは Root Motion を使用して全身でアニメーションを再生する
1 と 2 に関しては 参考にしたページ の解説が詳しい。
アニメーションの準備
アニメーションの準備やコントローラーの設定は 殴って吹き飛ばす を参照。
今回は「移動しながら発動できる通常攻撃」として Punching
、「専用の全身アニメーションがある必殺技」として Flying Knee Punch Combo
を Mixamo からインポートした。
Punching
は Root Motion = False
、Flying Knee Punch Combo
は Root Motion = True
とする。
Root Motion を使用しているかどうかの判定
- ABP_Manny または Retarget して作成した ABP を開く
- 「+」ボタンを押して Boolean の変数を追加する。今回は IsPlayRootMotion とした。
- EventGraph を開き、
Is Playing Anim Root Motion
の戻り値を変数にセットする。
AnimGraph の中で Get Character
→ Is Playing Anim Root Motion
と接続して値を取得することも可能だが、スレッドセーフではないと警告が出る。
EventGraph で取得した方が無難。
Node Blend Poses by bool uses potentially thread-unsafe call Get Character . Disable threaded update or use a thread-safe call. Function may need BlueprintThreadSafe metadata adding.
Animation の合成
-
Main States
を複数ノードの入力で使用するためNew Save cached pose
とUse cached pose
を使う。今回はbasic motion
という名前でキャッシュした。 -
Layered blend per bone
でアニメーションを合成する-
Base Pose
にbasic motion
を入力する -
Blend Pose
にDefault Slot
を入力する-
Default Slot
にbasic motion
を入力する
-
-
Layered blend per bone
を選択する-
Layer Setup
→Branch Filters
の 「+」ボタンを押す -
Bone Name
に上半身の付け根に当たるボーンを指定する。今回はJ_Bip_C_Sine
を指定 - (合成するアニメーションによる)
Blend Depth
を 3 に設定する - (合成するアニメーションによる)
Mesh Spece Rotation Blend
をTrue
に設定する
-
-
ここまでで「やりたいこと」の 1 は完了。
-
Blend Poses by bool
でアニメーションを合成する-
True Pose
にLayered blend per bone
を入力する -
False Pose
にDefault Slot
を入力する-
Default Slot
にbasic motion
を入力する
-
-
Active Value
に条件を入力する- 以下の AND 条件
-
Velocity > 0.0
(= Character が移動している) -
Is Playing Root Motion = False
(Root Motion の再生中ではない)
-
- 以下の AND 条件
-
これで「やりたいこと」の 2 と 3 が完了。
参考にしたページ
Discussion