Hi,
I am playing a sound when a player destroys blocks in a puzzle.
Sometimes the player will destroy one block, sometimes 5 blocks for example.
I had the code for playing the sound in with the destruction of the blocks, but this is giving me overlapping sounds, so 5 blocks are louder than 1 block etc.
I tried creating an AudioManager object to hold the AudioSource but I’m having some trouble with the script. It’s been pretty simple to code so that a block object knows when it’s been selected and when it is to be destroyed and having it play audio at the right time was pretty straight forward, but I can’t figure out how to get the AudioManager to check whether any blocks are being destroyed, and if any are, play the audio clip one time.
At the moment I can either have the audio play from within the block but then it will multiply and that’s a problem, or I can bind the audio clip to the trigger key, but then it will play when the trigger key is pressed even if nothing is being destroyed, which is a problem too.
Sorry if I made that over complicated, any tips would be appreciated.
Thanks.