1.步骤:
(1)导入模型
(2)添加状态机
(3)添加动画控制器
(4)通过脚本触发条件
(5)控制脚本代码
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class AnimalCs : MonoBehaviour
{
private Animator anim;
// Start is called before the first frame update
void Start()
{
anim = GetComponent<Animator>();
}
// Update is called once per frame
void Update()
{
if (Input.GetKeyDown(KeyCode.Alpha0))
{
// anim.SetBool("isRuning", false);
anim.SetInteger("id", 0);
}
else if (Input.GetKeyDown(KeyCode.Alpha1))
{
//anim.SetBool("isRuning", false);
anim.SetInteger("id", 1);
}
else if (Input.GetKeyDown(KeyCode.Alpha2))
{
//anim.SetBool("isRuning", false);
anim.SetInteger("id", 2);
}
else if (Input.GetKeyDown(KeyCode.Alpha3))
{
//anim.SetBool("isRuning", false);
anim.SetInteger("id", 3);
}
else if (Input.GetKeyDown(KeyCode.Alpha4))
{
anim.SetInteger("id", 4);
//anim.SetBool("isRuning", true);
//anim.SetTrigger("run2");
//anim.SetInteger("id2", 130);
}
}
}