Hello all,
I’m trying to get my brain back into Unity and C# after a hiatus and could use your help! When my player falls to his death and collides with a box collider, this IEnumerator is triggered. The only problem is that livesLost is updating to remove more than one life (as if it is being triggered continuously). I thought the 1 second yield would prevent that, but I guess I’m thinking incorrectly. Any help on how to fix this code to assure my player only loses one life per plummet would be greatly appreciated!
private IEnumerator DieAnim ()
{
CoinScript livesLost = this.GetComponent<CoinScript> ();
livesLost.UpdateLives (1);
iAmDying = true;
humanDeath.Play ();//plays the death sound
animator.SetInteger ("AnimState", 1);
yield return new WaitForSeconds (1);//Use the length of the animation clip as the wait time for yield
Application.LoadLevel (Application.loadedLevel);//reload the current level
}