Forum Discussion

🚨 This forum is archived and read-only. To submit a forum post, please visit our new Developer Forum. 🚨
Dae_K's avatar
Dae_K
Explorer
1 year ago
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.

 

  • 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

  • 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.