How to play sound when grabbing object in VR

Hi!

For a school project I’m working on a VR experience. I want a sound to play when grabbing an object and to stop when I put it down again. This is what I have until now but the sound always plays when I use the trigger instead of only when I’m grabbing the object. How is the best way to do this? Please simplify your answer, I’m a noob at unreal still and am only just starting to work with it

Hi Nxneteen,

Are you using the VR Template? If so, there is a ‘GrabComponent’ that you could leverage.

Check out this video for some more info on that. Later in the video he makes a top-hat, this will give an example of how to use those functions on the grab component for playing/stopping sound.

Let us know if you have more questions!

Hi! I have watched the video and made my object a GrabComponent, but they don’t mention anything about audio and I have no idea how to implement that myself. I’m guessing I can use On Grabbed and On dropped as triggers for playing the audio but I have very minimal knowledge of blueprinting in unreal engine so I have no idea! Please let me know if you can help some more :confused:

Using the ‘Spawn Sound Attached’ is one way to do it. But I think a more straightforward way might be to add an audio component to the Blueprint. (Click “Add” in the components panel)

You could then set the sound on this, and call Play/Pause/Stop events directly on it. (Drag created audio component from the components panel into the BP graph) You’d be tying into the On Grabbed/Dropped events like you mentioned.

Hope that helps!

1 Like

thank you this helped!

1 Like