How to detect if any button is pressed (not keyboard)

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Lazulily

I’m adding audio to my game and what I want to do is have an audio manager with the sfx and audio in it, and each audio player has it’s own script that will tell it when to play the audio. Is there a way I can do this? Can I put buttons into a group and if any of those buttons are pressed in that group are pressed a specific sound is played. I’m asking this because I would like to avoid having to connect a crap tonne of is pressed signals to one audio player.

Thanks in advance.

:bust_in_silhouette: Reply From: Noddy

Sounds like you want to use signals. Using signals — Godot Engine (stable) documentation in English

Basically, every time an event that should play audio happens you can emit a signal and use a function to catch it and play the intended audio effect.

Hi, thanks for getting back to me!
I am aware of signals but I want to avoid connecting each individual signal from each individual button in my game, which there are many of. I could do it through script but I want to see if there is an easier way and possibly a way that would be better for performance. But if not, I guess this is the only way to do it.
Thanks again, I hope to hear from you again soon!

Lazulily | 2022-02-11 02:04