J'essaie d'invoquer une animation de prise de vue dans la fonction de mise à jour, puis j'attends 0,5 seconde avant de générer un tir laser. Le code ci-dessous ne fonctionne pas pour moi. Que puis-je faire pour obtenir le résultat souhaité?Problème avec WaitForSeconds() dans Unity
void Update()
{
if (Input.GetMouseButtonDown (0))
{
animator.SetTrigger("Shoot"); // Start animation
WaitAndShoot();
}
}
IEnumerator WaitAndShoot()
{
yield return new WaitForSeconds(0.5f);
Instantiate (shot, shotSpawn.transform.position,shotSpawn.transform.rotation);
}
J'ai trouvé ce http://www.unitygeek.com/coroutines-in-unity3d/ très utile pour comprendre Coroutines dans Unity3d –