2016-11-11 11 views
0

このコードを使用するとアニメーションがユニティで再生されないのはなぜですか?どのようにしてアニメーションが終了するのをプログラムが待たせることができますか? JavaScript(またはUnityScript)ではこのアプローチが有効でした。ユニティアニメーション - yield yield new WaitForSeconds(secs)not working

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; 
} 
+0

:だからここ

はソリューションですか? –

+0

'Attack()'コルーチン関数を呼び出す/起動する必要があります。 'StartCoroutine(Attack());' – Programmer

答えて

0

これはコルーチンを実行する方法です:あなたは、それは文句を言わない仕事の通常の機能のようにそれを実行しようと

StartCoroutine(Attack()); 

または

StartCoroutine("Attack"); 

を。あなたはコルーチンを実行している

public void PlayAttack() 
{ 
    StartCoroutine(Attack()); 
} 

Learn More

関連する問題