0
爲什麼Unity中的動畫不能在Unity中播放?我該如何讓程序等待動畫結束?在JavaScript(或UnityScript)中,這種方法已經奏效。統一動畫 - 收益率返回新的WaitForSeconds(秒)不起作用
public bool Attacking { get; set; }
private Animator anim;
void Start()
{
anim = gameObject.GetComponent<Animator>();
}
private IEnumerator Attack()
{
Attacking = true;
anim.SetTrigger("Attack"); // this is not playing
yield return new WaitForSeconds(attackLength);
Attacking = false;
}
你在哪裏運行協同程序? –
您需要調用/啓動'Attack()'協程函數。 'StartCoroutine(攻擊());' – Programmer