# Unityでのアニメーション再生時に髪が揺れない

**URL:** <https://creatorsforum.live2d.com/t/topic/901>\
**Category:** トラブル報告\
**Tags:** sdk-for-unity\
**Created:** [2022 年 6 月 17 日午前 8:00 UTC](https://creatorsforum.live2d.com/t/topic/901 "2022-06-17T08:00:17Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![alice](https://avatars.discourse-cdn.com/v4/letter/a/779978/32.png) [@alice](https://creatorsforum.live2d.com/u/alice)\
**Post date:** [2022 年 6 月 17 日午前 8:00 UTC](https://creatorsforum.live2d.com/t/topic/901/1 "2022-06-17T08:00:17Z")

</div>

お世話になります。以下の現象についてご相談させてください。  
髪揺れを反映させるには特別な実装が必要なのでしょうか？

【Cubism Editorのバージョン】 Cubism 4.2.00  
【Cubism SDKのバージョン】 Cubism 4 SDK for Unity R5 beta2  
【OS名・バージョン】Windows10  
【開発使用ツール】Unity 2019.4.39f1  
【使用モデル】桃瀬ひより FREE版 ([https://www.live2d.com/download/sample-data/](https://www.live2d.com/download/sample-data/) より)  
【不具合再現手順】

1. Unityでプロジェクトを作成し、CubismSDK、モデル、モーションデータをインポート。
2. モデルに対してCubismSDKの付属サンプルの「CubismSampleController」をコンポーネント追加。
3. CubismSampleControllerに対し、「BodyAnimation」として「目の開閉」と「髪揺れ」を含むモーションを設定。
4. Unityでデバッグ実行。または、ビルドしてexeファイルを実行。  
【実行結果】  
・アニメーションが実行されて、モデルの目が開閉する。しかし髪揺れが反映されない。

【補足情報：1】  
使用したモーションデータは以下の通りで、髪揺れの動作確認用です。  
CubismEditor4.2.00 でのデバッグ実行においては正しく髪が揺れます。

```auto
{
	"Version": 3,
	"Meta": {
		"Duration": 4.7,
		"Fps": 30.0,
		"Loop": true,
		"AreBeziersRestricted": false,
		"CurveCount": 3,
		"TotalSegmentCount": 8,
		"TotalPointCount": 25,
		"UserDataCount": 0,
		"TotalUserDataSize": 0
	},
	"Curves": [
		{
			"Target": "Parameter",
			"Id": "ParamEyeLOpen",
			"Segments": [
				0,
				1,
				1,
				0.278,
				1,
				0.556,
				0,
				0.833,
				0,
				1,
				1.289,
				0,
				1.744,
				1.2,
				2.2,
				1.2,
				1,
				2.656,
				1.2,
				3.111,
				0,
				3.567,
				0,
				1,
				3.944,
				0,
				4.322,
				1,
				4.7,
				1
			]
		},
		{
			"Target": "Parameter",
			"Id": "ParamHairBack",
			"Segments": [
				0,
				0,
				1,
				0.444,
				0,
				0.889,
				1,
				1.333,
				1,
				1,
				2.011,
				1,
				2.689,
				-1,
				3.367,
				-1,
				1,
				3.811,
				-1,
				4.256,
				0,
				4.7,
				0
			]
		},
		{
			"Target": "PartOpacity",
			"Id": "PartArmA",
			"Segments": [
				0,
				1,
				0,
				4.7,
				1
			]
		}
	]
}

```

【補足情報：2】  
CubismSampleControllerの実装を以下の内容まで削ってみました。同様の結果です。

```auto
using Live2D.Cubism.Core;
using Live2D.Cubism.Framework.Motion;
using UnityEngine;

namespace Live2D.Cubism.Samples.OriginalWorkflow.Demo {
    [RequireComponent(typeof(CubismMotionController))]
    public class CubismSampleController : MonoBehaviour {
        [SerializeField]
        private AnimationClip _bodyAnimation;

        private CubismMotionController _motionController;

        private void Start() {
            _motionController = this.FindCubismModel().GetComponent<CubismMotionController>();
            _motionController.PlayAnimation(_bodyAnimation, priority:CubismMotionPriority.PriorityIdle);
        }
    }
}

```

---

<div class="post-metadata">

**Author:** ![ono-at-live2d-com](https://sea1.discourse-cdn.com/flex015/user_avatar/creatorsforum.live2d.com/ono-at-live2d-com/32/167_2.png) [@ono-at-live2d-com](https://creatorsforum.live2d.com/u/ono-at-live2d-com)\
**Post date:** [2022 年 6 月 20 日午前 2:39 UTC](https://creatorsforum.live2d.com/t/topic/901/2 "2022-06-20T02:39:45Z")

</div>

@alice 様

ご質問誠にありがとうございます。  
Live2Dスタッフでございます。  
いつも弊社製品をご愛顧くださり誠にありがとうございます。

物理演算によって値が操作されるパラメータは、モーションから操作することはできません。

物理演算は、出力先のパラメータの値を計算結果の値で上書きします。  
そのため、モーション内で物理演算が管理しているパラメータを操作しても、物理演算によって上書きされてしまいます。

モーションから物理演算が管理するパラメータの値を操作をする場合、ユーザ側で物理演算適用後に値が適用されるコンポーネントを実装することで実現できる可能性があります。

よろしくお願いいたします。

---

<div class="post-metadata">

**Author:** ![alice](https://avatars.discourse-cdn.com/v4/letter/a/779978/32.png) [@alice](https://creatorsforum.live2d.com/u/alice)\
**Post date:** [2022 年 6 月 20 日午前 3:30 UTC](https://creatorsforum.live2d.com/t/topic/901/3 "2022-06-20T03:30:15Z")

</div>

ご回答を頂きありがとうございます。

物理演算の適用に関連する仕様が理解できました。  
記載頂きましたように、物理演算適用後の処理を実装してみたいと思います。
