Skip to main content
Participant
July 7, 2024
Solved

How to make grab interactable to make a sound

How do I trigger a sound when I grab something?

Things I have tried:

* Interactable Unity Event Wrapper to be triggered when Grab Interactable gets selected.

 

MikyjaxAnswer
Inspiring
July 11, 2024

I would have a gameObject not related directly to it with script "SoundHandler", with a public function "PlayGrabbedSound()" and then bring that game object in the Select of your event wrapper and select the script, then the function.

The soundHandler script would have the audiosource component and the reference to the sound clip that will be played in the function.

If you whant to do that at runtime, you might want to have the soundHandler subrscribing to the grabEvent or something in those lines...

Hope that helps, I'm quite new to this and I'm sure there are better way to do it, but that would work.

 

1 reply

MikyjaxAnswer
Inspiring
July 11, 2024

I would have a gameObject not related directly to it with script "SoundHandler", with a public function "PlayGrabbedSound()" and then bring that game object in the Select of your event wrapper and select the script, then the function.

The soundHandler script would have the audiosource component and the reference to the sound clip that will be played in the function.

If you whant to do that at runtime, you might want to have the soundHandler subrscribing to the grabEvent or something in those lines...

Hope that helps, I'm quite new to this and I'm sure there are better way to do it, but that would work.