• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

GML Enemy sound effect stack issue (simultaneous sound play) [solved]

Samples

Member
Hello I'm new to this account but not to this place lol anyways

upload_2019-9-2_12-57-0.png

There is multiple enemies that are lined up.
After a certain time, they open up, shoot, and play a sound.

the issue is since they all are next to each other, and they all open up at the same time....the shot sound is rather....loud, as it's stacking. Is there a way to keep it so the sound effect plays at it's default volume, even if multiple enemies are playing the sound simultaneously?
 

GMWolf

aka fel666
You can use the audio_is_playing function to check if a particular sound is played.
That way you can check for it to make sure only one instance of each sound plays at a time.

Another option is to stop a sound before playing it using audio_stop_sound, that way a sound can repeat even if it hasn't finished.

Finally, if you want sounds to overlap and repeat, but not play multiple during the same frame, you could set a global variable "played_sound_this_frame" (or something to that effect) to try when you play a sound, and check that to make sure its unique.
Then reset the value to false at the end / beginning of the frame.
 

Samples

Member
Hi, thanks for responding. I am using GM8.0 pro and therefore the audio_ commands I am not using, but rather sound_play etc.

The problem is, is when I try to check if a sound is playing, or isn't playing, it doesn't seem to matter, since it checks it beforehand, not at the same time. so since it isn't playing before hand, it gives it the ok to play the sound....which is where the issue happens....cause its super loud as it's playing the same sfx 5 times. I do not wish any sounds to overlap of the same sfx. I don't think the stopping the sfx and then playing the sfx worked
 

Samples

Member
update, having the sound stop and then play did work. it didn't work the first test run for whatever reason, so I'll have to keep checking to see if it works everytime. thankyou and I'll get back to you later.
 
Top