首先获取脚本组件,然后就可以调用它的方法了。
void Start ()
{
anim = GetComponent<Animator> ();
gunAim = GetComponentInParent<GunAim>();
}
void Update ()
{
if (Input.GetButtonDown("Fire1") && Time.time > nextFire && !gunAim.GetIsOutOfBounds())
{
anim.SetTrigger ("Fire");
...
}
}
本文介绍如何在Unity中使用C#脚本控制动画播放。通过获取Animator组件并监听Fire1输入事件来触发动画播放,同时检查是否超出边界。
424

被折叠的 条评论
为什么被折叠?



