Question by
demonjanitor · Sep 08, 2020 at 12:48 PM ·
c#audio
Audio clip repeating infinitely in update,Audio clip repeating error
Hello! I have a problem that seems like it should be super duper simple but I've only been learning C# for about two or three days now. I have a script that causes the level to restart whenever the player drops below five units vertically, and also plays an audio clip associated. The problem lies in the fact that because the player is constantly below the kill boundary, it keeps spamming the audio clip. I've tried a couple things now to no avail. I'm not entirely sure how to get a bool to work for this or a toggle shield.
void FixedUpdate()
{
if (RigidBody.position.y < -5f)
{
FindObjectOfType<GameManager>().GameOver();
AudioManager.instance.Play("PlayerFall");
}
}
Comment