#概要
SDUnityChanを使用して歩くモーションを設定しました。
すると歩くモーションの最初に目を閉じてしまいます。
これがなぜか知りたいです。
■やってみたこと
1、目を閉じる部分に関する関数(OnCallChangeFace)をコメントアウト
結果:animatorでwalkを再生する際に下記のようなエラーが発生。(画像参照)
これが該当の関数があるスクリプトです。
C#
1using UnityEngine; 2using System.Collections; 3 4namespace UnityChan 5{ 6 public class FaceUpdate : MonoBehaviour 7 { 8 public AnimationClip[] animations; 9 Animator anim; 10 public float delayWeight; 11 public bool isKeepFace = false; 12 public bool isGUI = false; 13 14 void Start () 15 { 16 anim = GetComponent<Animator> (); 17 } 18 19 void OnGUI () 20 { 21 if (isGUI) 22 { 23 GUILayout.Box("Face Update", GUILayout.Width(170), GUILayout.Height(25 * (animations.Length + 2))); 24 Rect screenRect = new Rect(10, 25, 150, 25 * (animations.Length + 1)); 25 GUILayout.BeginArea(screenRect); 26 foreach (var animation in animations) 27 { 28 if (GUILayout.RepeatButton(animation.name)) 29 { 30 anim.CrossFade(animation.name, 0); 31 } 32 } 33 isKeepFace = GUILayout.Toggle(isKeepFace, " Keep Face"); 34 GUILayout.EndArea(); 35 } 36 } 37 38 float current = 0; 39 40 void Update () 41 { 42 43 if (Input.GetMouseButton (0)) { 44 current = 1; 45 } else if (!isKeepFace) { 46 current = Mathf.Lerp (current, 0, delayWeight); 47 } 48 anim.SetLayerWeight (1, current); 49 } 50 51 52 //アニメーションEvents側につける表情切り替え用イベントコール 53 /* public void OnCallChangeFace (string str) 54 { 55 int ichecked = 0; 56 foreach (var animation in animations) { 57 if (str == animation.name) { 58 ChangeFace (str); 59 60//walkのアニメーションでここになぜかsmile@sd_dmdがはいり、目を閉じてしまいます。 61 62 break; 63 } else if (ichecked <= animations.Length) { 64 ichecked++; 65 } else { 66 //str指定が間違っている時にはデフォルトで 67 str = "default@unitychan"; 68 ChangeFace (str); 69 } 70 } 71 } 72*/ 73 void ChangeFace (string str) 74 { 75 isKeepFace = true; 76 current = 1; 77 anim.CrossFade (str, 0); 78 } 79 } 80} 81
2、Walking@loopにアニメーションイベントが設定されているか確認。(下記画像参照。)
結果:設定されていなそう。(確認方法があっているかあまり自身がありません。)
#知りたいこと
このエラーが出ている原因を知りたいです。
おそらくどこかのanimation event で呼ばれているとは思うのですが特定する方法はありませんか。
足りない情報などございましたら追記いたします。
どなたか回答していただけないでしょうか。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2020/01/10 16:00 編集