Hi.
I’ve been having trouble getting audio.PlayOneShot() to play only once, and not overlap with the same sound each frame, cause Update() is getting called each frame. The thing I want to do is to play a sound once a boolean is true.
Things I’ve tried:
- I created a new boolean variable, and deactivated it after the audio.PlayOneShot() line (if the boolean is true, play a sound, after that line, deactivate it)
- I created a boolean function, and play the sound after the “return true;” line
- Call it in another (regular void) function (same result, the Update() function is still calling the newly created function each frame),
- I have also tried to Invoke() that function.
How could I play a sound when the boolean mentioned in the beginning is turned true?