I have a litte IENumerator that ‘zaps’ my player. It is supposed to make a noise and set off a particle effect before moving the player to a different position. For some reason the sound doesn’t play until AFTER everything else even though it is the first command. I think I’m misunderstanding something very fundamental to Unity’s handling of sound…
IEnumerator ZapPlayer()
{
audioPlayer.Play();
playerScript.Zap(true);
yield return new WaitForSeconds(0.5f);
playerScript.Zap(false);
RestartLevel();
}
Zap(true) starts my particle, Zap(false) stops it. The pause is to allow for the player to see the effect/hear the sound before they are teleported.
RestartLevel() just moves the player’s location.
Why does the sound not play until after the RestartLevel() line?