How to play sounds once when you do a certain action in gdevelop

I have decided to make this topic to help people out since I had this issue but fixed it. Say you want a sound to play once whenever you hover your mouse over a button and you can do this several times and sound restarts back to the beginning every time. But it doesn’t work? Well, I can explain what you did. First, you added the condition, “When mouse hovers over [your button name here]” and next to it you add action “Play [Your sound file name here], vol.: 100, loop: No”

Now you test it out by having a preview and when you do the preview of the game, and hover your mouse over the button, it sounds extremely loud and seems to not be playing it correctly. Well, the solution is to add a “Trigger once while true” condition that should go after the “When mouse hovers over [your button name here]” condition.

You can also use this with jump sounds. Such as, adding in a player has jumped condition and adding in a trigger once while true event to go after this. And then you add your action that is suppose to play the sound. This has worked out for me several times and is very much helpful.

I hope this helps some people out with sounds.

Hi, I don’t want to be nitpicking but since your post is intended to help people, it is important to be as precise as possible. There is no “Toggle once while true” condition in Gdevelop, what you mean is Trigger once while true.

Yeah, I was in a rush when I typed that, thanks, I just made the edit

1 Like