AudioTrigger.PlayAudio() method.AudioTrigger ships in the Interaction SDK samples, in the Oculus.Interaction.Samples assembly, under the Oculus.Interaction namespace. That assembly is auto-referenced. The Inspector wiring below, and any script outside a custom assembly definition, need no setup. A script inside its own assembly definition needs a reference to Oculus.Interaction.Samples.Audio. This container keeps the audio separate from the interaction components.Audio for the sound.AudioTrigger looks for an Audio Source on its own GameObject at startup. Adding the component does not add an Audio Source for you, so step 3 is required.Audio GameObject and add a PointableUnityEventWrapper component. In the event slot you want, drag in the sound GameObject, then pick AudioTrigger and PlayAudio ().AudioTrigger holds one set of clips, so a grab sound and a release sound need one instance each.MyProp
└── Audio
├── PointableUnityEventWrapper
│ When Select -> GrabSound.AudioTrigger.PlayAudio ()
│ When Unselect -> ReleaseSound.AudioTrigger.PlayAudio ()
├── GrabSound AudioSource + AudioTrigger
└── ReleaseSound AudioSource + AudioTrigger
| Property | Description |
|---|---|
Audio Source | The Audio Source that plays the clip. Leave it empty to use the Audio Source on the same GameObject. |
Audio Clips | A list of audio clips. The clip is chosen at random. With two or more clips, the pick never repeats the clip played immediately before it. A single-clip list plays that clip every time. |
Volume | The default playback volume of the audio clip. Defaults to 0.7. |
Volume Randomization | A random range of volumes at which to play the audio clip. |
Pitch | The default pitch of the audio clip. Defaults to 1. |
Pitch Randomization | A random range of pitches at which to play the audio clip. |
Spatialize | Overrides the Spatialize property on the attached AudioSource. Enabled by default. |
Loop | Overrides the Loop property on the attached AudioSource. |
Chance To Play | The likelihood that the sample will play when called. Defaults to 100. |
Play On Start | Indicates if the audio clip should play when Start() is called on this object. |
PlayAudio() that reaches playback writes Spatialize and Loop onto the attached Audio Source. It also writes a volume and a pitch, taking each from either the flat field or the random range. Values authored on the Audio Source itself are replaced, so configure playback on the Audio Trigger.PlayAudio() is the only playback method on the component, and there is no matching stop method. To halt a looping clip, wire Stop on the Audio Source component.