ユニティでアニメーションコントローラーを使ってモーションの推移をやっているのですがどう使えばいいのか全くわかりません
矢印に条件を入れスクリプトにてその判定を出すというところまではわかりますが 自分のやり方では明らかに効率が悪い気がしてなりません
このように一つの動作をするごとに登録してる条件をすべて命令してやらないといけないのでしょうか。
C#
1using System.Collections; 2using System.Collections.Generic; 3using UnityEngine; 4 5public class AnimationController : MonoBehaviour { 6 private Animator animator; 7 // Use this for initialization 8 void Start () { 9 animator = GetComponent<Animator> (); 10 11 } 12 13 // Update is called once per frame 14 void Update () { 15 float h = Input.GetAxis ("Horizontal"); 16 float v = Input.GetAxis ("Vertical"); 17 if (v > 0.7f) { 18 animator.SetBool ("stop", false); 19 animator.SetBool ("front", true); 20 animator.SetBool ("walkf", false); 21 animator.SetBool ("turn R", false); 22 animator.SetBool ("turn L", false); 23 } else if (v > 0.0f) { 24 animator.SetBool ("stop", false); 25 animator.SetBool ("walkf", true); 26 animator.SetBool ("front", false); 27 animator.SetBool ("turn R", false); 28 animator.SetBool ("turn L", false); 29 } else if (h > 0) { 30 animator.SetBool ("stop", false); 31 animator.SetBool ("turn R", true); 32 animator.SetBool ("walkf", false); 33 animator.SetBool ("front", false); 34 animator.SetBool ("turn L", false); 35 } else if (h < 0) { 36 animator.SetBool ("Stop", false); 37 animator.SetBool ("turn L", true); 38 animator.SetBool ("walkf", false); 39 animator.SetBool ("front", false); 40 animator.SetBool ("turn R", false); 41 }else if(h == 0){ 42 animator.SetBool ("Stop", true); 43 animator.SetBool ("turn L", false); 44 animator.SetBool ("walkf", false); 45 animator.SetBool ("front", false); 46 animator.SetBool ("turn R", false); 47 } 48 49 } 50 } 51 52 53 54 55 56 57
以上がソースコードです。
尚これでもまともに動きません 歩き(walkf)と走り(front)とストップの推移だけならなんとか似たような方法でできましたが、この方法では一つモーションの種類を増やすごとにいちいち追加しないといけず非常に非効率な気がします、こういったものなのでしょうか?
まだユニティもプログラムも1ヶ月ほどしかやってないしここで質問するのも初めてなので何か質問する形式が間違ってるかもしれませんがよろしくおねがいします
すでにキャラクターを動かすプログラムは別スクリプトファイルで登録していて、キャラクターコントローラーにてそのキャラを制御しています
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/06/02 01:34