添加一个动画状态机
点击一个动画,点击一个鼠标右键选择第二着构建动画切换
Controller 放置你设置的动画状态机
Avatar 是你的任人物骨骼
Apply Root Motion 勾选这个选项人物动画播放时,会根据脚下的指示移动,正常状态下不勾选。
public class Rotos : MonoBehaviour {
private Animator an;
void Start () {
an= GetComponent<Animator>();//添加鑫动画的组件
}
void Update () {
if (Input.GetKeyDown(KeyCode.Q))//播放跑的动画
{
an.SetFloat("Run", 1.0f); //小数类型
an.SetBool("RunANDWalk", true);//布尔类型
}
if (Input.GetKeyDown(KeyCode.W))//播放走
{
an.SetInteger("Walk", 1);//int类型
}
if (Input.GetKeyDown(KeyCode.E))//播放跳
{
an.SetTrigger("Jump");//触发器类型
}
}
}