+++ date = "2023-12-21" tags = ["ue5","3d"] title = "ue5を触ってみた9" slug = "ue5" +++ 今回は、髪の毛が体を貫通する問題の修正と歩くモーションを変更する方法です。 ### KawaiiPhysics https://github.com/pafuhana1213/KawaiiPhysics このpluginは素晴らしい働きをし、完璧に動作します。 ただし、このpluginはc++クラスを追加する必要があります。 c++クラスを追加するとwindows側でprojectを起動できなくなります。私はmacからwindowsに送ってbuildしています。 したがって、[こちら](https://forums.unrealengine.com/t/4-14-cannot-open-project-anymore/379795/6)にあるように.uprojectを修正して起動し、c++クラスを追加後に右クリック、`generate visual studio project files`から`.sln`を作成してrebuildします。rebuildする際もあらゆる依存関係でerrorが出るかもしれません。ue5は基本的に壊れているので、あらゆる問題が発生する可能性があります。 このpluginの使い方は、vroid studioで後ろ髪のboneを確認したあと、そのboneをrootに設定し、各種[limit](https://qiita.com/YuukiOgino/items/7f3198a90dab43019f26)を設定し、指定のboneを貫通しないようにします。`Sphere Limit`,`Capsule Limit`, `Plane Limit`があります。 ![](https://raw.githubusercontent.com/syui/img/master/other/ue5_ai_20231224_0001.png) ちなみに、今回は`UE_5.3/Engine/Build/BatchFiles/Build.bat`を動かすのに相当手間取りました。 1. pluginを使うにはc++クラスを追加する必要があるらしい 2. 追加するとwindowsでuprojectが開かなくなる 3. とりあえずc++なしでuprojectを開いてc++クラスを追加 4. slnでrebuildが通らない。visual studioが警告ありとか出てる 5. visual studioで.net framework sdk 4.8.0をインストールしろと言われる 6. .net framework 4.8のインストーラーがblockされる 7. .net framework 4.8.1とその他の.net関連をを手動でインストールする 8. 1回目のrebuildが何故か失敗する 9. 2回目でやっと`UE_5.3/Engine/Build/BatchFiles/Build.bat`が動作する 10. uprojectが正常に開くようになる こんな感じでue5が動作する環境を構築してる時間のほうがゲーム開発してる時間より長い。ゲーム開発をしている場合ではない。 ### walk/run, land state `ABP_Player`でwalk/runのstateを編集したり、スタート時のダッシュをアニメモンタージュで調整したりしました。 [/ai/video/#ue5_ai_0006.mp4](/ai/video/#ue5_ai_0006.mp4) ## v5.3 ### for mac mac(apple silicon)でも動作しますが、`package build`は鬼門です。絶対にやめましょう。時間がもったいない。 ue5は、基本的にwindowsのpakcage buildはすぐに通りますが、それ以外では難しいでしょう。 たとえ1度だけbuildが通ったとしても、もし開発を続ける場合、windowsとmacの両方で動作を安定させることはできません。 windowsで開発するのがおすすめです。macでの開発はやめておきましょう。 ### vrm https://github.com/ruyo/VRM4U/releases [vroid](https://vroid.com/)を読み込むpluginである[vrm4u](https://ruyo.github.io/VRM4U/)を使用します。現在、[vroid sdk](https://github.com/pixiv/vroid-sdk-developers/discussions/118)というものも登場しています。 macで使用するには大変ですが`./Plugins/VRM4U/ThirdParty/assimp/lib/Mac/libassimp.a`を用意してください。独自buildが必要です。 https://ruyo.github.io/VRM4U/03_mac ### outline ![](https://raw.githubusercontent.com/syui/img/master/other/ue5_ai_20231202_203956.png) ![](https://raw.githubusercontent.com/syui/img/master/other/ue5_ai_2023-12-09_16.34.39.png) これはoutline(アウトライン)やnormal line(法線)と一般に言われているものです。 それをoverlay materialで実現しています。 ### 調整 基本的には[Superhero Flight Animations](https://www.unrealengine.com/marketplace/ja/product/superhero-flight-animations)を使用してmodelの調整を行います。 `Superhero Flight Animations`は`./Content/SuperheroFlight/Blueprints/Characters/BP_Player_UE5`で`./Content/SuperheroFlight/Blueprints/Components/BP_SuperheroFight`を読み込んでいます。 `BP_Player_UE5`を開いて`SuperheroFlightComponent`のところが設定ファイルになっていて、例えば、`flying speed`、つまり、飛行速度などを変更できます。 基本的には、ここのassetsにanimationを入れることで機能します。もし機能しない場合の変更箇所を書きます。 ![](/img/ue-2024-02-01-7.36.38.png) いくつかのanimationは自分で用意したものに切り替えます。 `ABP_Player_ai`, `BP_Player_UE5`を新たに用意し、それを読み込むようにします。 `./Content/SuperheroFlight/Characters/Mannequins/Animations`をリターゲットしてanimationを作成、それをanim montageにします。 ### idle/walk かっこいいものに切り替えます。おかしな移動になっていました。 - ABP_Player_ai : `AnimGraph > Locomotion > idle` - ABP_Player_ai : `AnimGraph > Locomotion > walk` ![](/img/ue-2024-02-01-7.36.36.png) 使用しているanimationに`root motion`を設定します。 ![](/img/ue-2024-02-01-7.36.37.png) ### jump かっこいいものに切り替えます。`root-motion`が動きませんでした。 - ABP_Player_ai : `AnimGraph > Locomotion > jump` - ABP_Player_ai : `AnimGraph > Locomotion > idle` - RTG_ai : `target`, `チェーンマッピング > root`を`FK > 平行移動モード > Globally Scaled`に設定 root motionをenableにしても動きません。原因はIKリターゲットしたときrootが動いていないために起こります。animationを開いてsrcとtargetを比較してみると、srcのほうはrootが動いていますが、targetのアニメは動いていません。具体的には、srcはlocationが変動しますが、targetは変動していません。 bone(ボーン)のrootを選択してFKの平行移動モードをGlobally Scaledに設定します。 これでtargetのrootが変動しているのを確認後、リターゲットし、montageを作成します。 ![](/img/ue-2024-02-01-6.59.18.png) ### hover ものに当たった時のanimationです。 - ABP_Player_ai : `EventGraph > Play hover fligh start montage notify event` ![](/img/ue-2024-02-01-7.31.12.png) ## land 着地するときのanimationです。 - BP_SuperheroFlighComponent : `EventGraph > Hit Event Collapse Graph` ![](/img/ue-2024-02-01-7.14.49.png) `Play anim montage`に指定したものを使用するように変更します。 指定したanim montageの通知に`BPANS_SetlsSuperheroloading`などを追加します。既存のanim montageである`./Content/SuperheroFlight/Characters/Mannequins/Animations/Flight/Land/`を参考にしてください。 ![](/img/ue-2024-02-01-7.04.47.png) ## sprint ダッシュです。これは`BP_Player_UE5 > Input Event Graph > sprint`の最後に`Start Flight`を入れます。 - BP_Player_UE5 : `Input Event Graph > sprint` ## kawaiiphysics https://github.com/pafuhana1213/KawaiiPhysics/releases vrmの髪の毛などを動かすために使います。 - ABP_Player_ai : `AnimGraph` ![](/img/ue-2024-02-01-7.24.20.png) 主に`hair1_08`, `hair1_09`, `hair1_10`を指定して各種limitを入れ、調整していきます。 limitは髪の毛が体を貫通しないようにするためのものです。主に`Spherical Limits`の丸形と`Capsule Limits`の筒型を使用します。大きさや傾きなどを調整してください。`head`や`hip`, `arm`を指定するといいでしょう。