0 votes

So in short I have a scene with background music and five buttons. Each time a button is pressed, a looping sound plays on top of the background music (one different looping sound per button).

How would I go about making it so each time a button is pressed, the looping sound of the previous one is muted and the new one is unmuted (while the background music keeps playing as normal)I tried doing something with different buses but I can't quite figure it out. I believe the answer is pretty simple but I can't quite grasp it. Thanks in advance.

in Engine by (12 points)

2 Answers

+1 vote

A solution would be to have a node for each sfx and make some checks like, if Audio.playing() == true, then Audio.stop(), for all the nodes that you dont want to play. another aproach would be to have only one node for sfx, and load and play a sound when you want to, like Audio.stream = soundyouwant and then Audio.play().

by (30 points)

Thanks but is there a way to mute the audio instead of stopping it? (so it keeps playing even if its muted)

0 votes

Godot has audio buses (which are like audio channels). so you can just assign the background music to a bus and the game sounds to another, and just mute the game sounds bus.

Godot has a documentation page for audio buses

by (29 points)
reshown by
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.