VRMの表情ブレンドシェイプをUnityのAnimationから操作する
https://www.youtube.com/watch?v=GCSyxioexl8
表情アニメーションを出力してVRMモデルで共通して使えたら便利
UniVRMはBlendShapeKeyを使ったアニメーションのエクスポートは未対応
BlendShapeProxyを使うスクリプトを作ってそれを操作するAnimationClipをつくる
Animaionから操作するためのコンポーネントの作成
とりあえずpublicな変数を使って単純なプログラムを作る
BlendShapePresetごとに0.0~1.0で入力できるようにする
アタッチしたモデルのVRMBlendShapeProxyを取得
updateごとに適用させる
_.iconInspectorから項目を追加できると便利だから実装したい
?.iconコードを読んでいたらSetValuesがあったのでこっちを使った方がいいかもしれない
code:c#
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using VRM;
public class proxy4Anim : MonoBehaviour
{
// 拡張 : (VRoid)
private VRMBlendShapeProxy targetProxy;
// Start is called before the first frame update
void Start()
{
targetProxy = this.gameObject.GetComponent<VRMBlendShapeProxy>();
}
// Update is called once per frame
void Update()
{
applyShapeKey();
}
void applyShapeKey()
{
targetProxy.SetValue("A", A, false);
targetProxy.SetValue("I", I, false);
targetProxy.SetValue("U", U, false);
targetProxy.SetValue("E", E, false);
targetProxy.SetValue("O", O, false);
targetProxy.SetValue("BLINK", BLINK, false);
targetProxy.SetValue("BLINK_L", BLINK_L, false);
targetProxy.SetValue("BLINK_R", BLINK_R, false);
targetProxy.SetValue("ANGRY", ANGRY, false);
targetProxy.SetValue("FUN", FUN, false);
targetProxy.SetValue("JOY", JOY, false);
targetProxy.SetValue("SORROW", SORROW, false);
targetProxy.SetValue("EXTRA", EXTRA, false);
targetProxy.SetValue("LOOKUP", LOOKUP, false);
targetProxy.SetValue("LOOKDOWN", LOOKDOWN, false);
targetProxy.SetValue("LOOKLEFT", LOOKLEFT, false);
targetProxy.SetValue("LOOKRIGHY", LOOKRIGHT, false);
// 拡張 : (VRoid)
targetProxy.SetValue("SURPRISED", SURPRISED, false);
targetProxy.Apply();
}
}
Inspectorから操作できる
https://gyazo.com/019b7bc3e4f2603077a1acda58096d19
!.iconPlayしないとモデルには反映されない
AnimationClipの編集
AnimatiorController,AnimationClipを作って Playしながら編集する
rootのボーンの回転と位置は指定すると編集しやすい
https://www.youtube.com/watch?v=GCSyxioexl8
ほかのアニメーションと組み合わせる
ほかのhumanoidのアニメーションと組み合わせるときはAnimatorControllerでレイヤーを分けるとやりやすい
アバターマスクを設定すれば上書きしない箇所を指定できるけど必要ないかもしれない
https://gyazo.com/16c8df7201256ed2c6e2bac367fec1b9
https://youtu.be/DO7wHXayXMA
ほかのVRMモデルに適用する
Animatorの項目に同じAnimatorControllerを設定
作成したプログラムをアタッチする
うごく
無いBlendshapeは再生されない
例) SURPRISEDはVRoidStudioで出力したモデルにはあるけど標準ではない
https://youtu.be/vejHOkWtwFs
UnityPackeageでエクスポートすれば表情アニメーションを共有できるはず