左右キーでモーションが変わります。
初めて動画とりましたが画質悪いですね。。。
以下キャラコントロールのソースコード
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
/// キャラコントロール
public class CharaCtrl : MonoBehaviour {
/// モーションインデックス
enum MotionIdx
{
Walk = 0,
Run,
Damage,
Stabbing,
ReadyPhysical,
ReadyMagic,
Guard,
Evade,
Swinging,
Magic,
Skill,
Throw,
Victory,
Sick,
Item,
Escape,
Charge,
Down,
Jump,
EndMOtion,
};
/// モーションリスト
string[] MotionList =
{
"Walk",
"Run",
"Damage",
"Stabbing",
"ReadyPhysical",
"ReadyMagic",
"Guard",
"Evade",
"Swinging",
"Magic",
"Skill",
"Throw",
"Victory",
"Sick",
"Item",
"Escape",
"Charge",
"Down",
"Jump",
"EndMOtion",
};
/// アニメ
[SerializeField]
private Animator anim;
/// テキスト
[SerializeField]
private Text text;
/// モーション番号
private int motion;
// Use this for initialization
void Start ()
{
motion = 0;
}
// Update is called once per frame
void Update ()
{
if (Input.GetKeyDown(KeyCode.LeftArrow))
{
text.text = MotionList[motion];
anim.Play(MotionList[motion]);
motion--;
if (motion < 0)
{
motion = (int)MotionIdx.Jump;
}
}
if (Input.GetKeyDown(KeyCode.RightArrow))
{
text.text = MotionList[motion];
anim.Play(MotionList[motion]);
motion++;
if (motion > (int)MotionIdx.Jump)
{
motion = 0;
}
}
}
}
以下適当に作ったAnimator
Animatorってどうやって作ったら効率がいいのか分かんないですね。
素材はぴぽやさんから使わせてもらいました。
感謝感激雨あられ
ぴぽや
http://piposozai.blog76.fc2.com/