首先获取脚本组件,然后就可以调用它的方法了。
void Start ()
{
anim = GetComponent<Animator> ();
gunAim = GetComponentInParent<GunAim>();
}
void Update ()
{
if (Input.GetButtonDown("Fire1") && Time.time > nextFire && !gunAim.GetIsOutOfBounds())
{
anim.SetTrigger ("Fire");
...
}
}版权声明:本文为wanglining1987原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。