Sound\Music repeats even if repeat sound set to "no"

Hi.

I think I have found one more bug :smiling_imp:

This time,I would like to play a sound only once if 2 objects collided.
But the sound plays multiple times even if I set repeat sound to “no”.

Same results for music.
I think if I set repeat sound to “no” it should play the sound only once at the time even if the condition is continuous. :confused:

I have uploaded an example to here:
docs.google.com/file/d/0B1sXiYO … sp=sharing

I think this isn’t a bug, GD3 check every tick (frame) your event, and found that the objects collide, so play the sound (and not repeat it), but in the next frame, the objects collide and play the sound again.

If you want to check the collision one time add a variable condition:

Tank1 collide with tank2 and variable(sound_repeat) = 0: ........Play sound "explosion.wav" ........Do = 1 variable(sound_repeat)

Hi.

Thanks for the answer but I have the same result even If I use a variable as a condition,because the value of variable also true every frame.The problem is not really that the sound is repeated,the problem is that most likely , the sound start playing every frame as long as the condition is true.The only way I can solve this problem If I use a timer so the sound played only once in the specified time:

object1 is not in collision with object 2 : repeat is = 1,reset timer,pause timer object1 is in collision with object 2 and repeat is = 1 :playsound = 1,start timer playsound is = 1 : play sound after 0.1 sec : repeat is = 0,playsound is = 0

This is the only way I can get it to work.I’m sure if I set repeat to “no” it should stop the sound from playing more times even if the condition is true.It should play the sound only once and wait for the condition to be false then true again if repeat is set to “no”.
Well,I hope so :blush:

The repeat parameter is only used to specify if the sound must loop when it reaches its end. So you need to manually ensure that the action used to play the sound is only called once :slight_smile:

The problem is (if your example works) that the sound will be played 0.1 seconds, then, assuming 60fps, the sound will be played 6 times :wink:
I suggest this:

Object1 collide with Object2 and variable(repeat) = 1: ........Play sound "explosion.wav" ........Do = 0 variable(repeat) Object1 not collide with Object2 and variable(repeat) = 0: ........Do = 1 variable(repeat)

With this, the sound only will be played one time in each collision, if objects don’t collide and then collide again, the sound will be played again.

Well,6 is still less than hundreds :laughing:
Yes I have noticed that after,it still played multiple times so I have changed the timer from 0.1 to 0.01,it sounds good now,play the sound only once on every collision,but your suggestion makes more sense.The timer was my initial solution so I was stick to that and I based on the timer.I didn’t even notice that I don’t need the timer any longer :mrgreen:

Thanks for your help again. :slight_smile:

I had a similar issue with the sound repetitively playing. I solved it by adding “Trigger Once” to the condition that plays the sound.

3 Likes