标签:赋值 左右 执行 run span vector ica key string
using UnityEngine; using System.Collections; public class PlayerAnimation : MonoBehaviour { float ver; private Animator ani; void Awake() { ani = GetComponent<Animator> (); } void Update() { ver = Input.GetAxis ("Vertical"); //设置动画状态机参数 // ani.SetInteger ("Number",(int)Mathf.Abs (ver)); ani.SetInteger (HashIDs.instance.Number,(int)Mathf.Abs (ver)); //前键,人物朝前,后键,人物朝后 if (ver > 0) { transform.eulerAngles = Vector3.zero; } else if(ver < 0){ transform.eulerAngles = Vector3.up * 180; } //按下空格,玩家喊叫 if (Input.GetKeyDown (KeyCode.Space)) { ani.SetTrigger ("Shout"); } } }
上面的这个脚本挂载人物身上达到控制任务执行动画的效果
接下来就是设置动画的速度赋值
using UnityEngine; using System.Collections; public class HashIDs : MonoBehaviour { public static HashIDs instance; void Awake() { instance = this; } public int Speed; public int Number; public int Idle; public int Run; void Start() { Speed = Animator.StringToHash ("Speed"); Number = Animator.StringToHash ("Number"); Idle = Animator.StringToHash ("Idle"); Run = Animator.StringToHash ("Run"); } }
标签:赋值 左右 执行 run span vector ica key string
原文地址:http://www.cnblogs.com/VR-1024/p/6021118.html