ultimatexr-unity icon indicating copy to clipboard operation
ultimatexr-unity copied to clipboard

Add onTrigger option for audio playback

Open tomkingkong opened this issue 3 years ago • 1 comments

Added a trigger event to GrabManager enabling the AudioManipulation script to play sounds when a grabbableObject is "triggered".

tomkingkong avatar Aug 01 '22 00:08 tomkingkong

Hi @tomkingkong,

Thanks for taking the time to make this pull request. I see that you understood how the manipulation events work and changed all dependencies nicely. However, I'm not sure using the trigger button on a grabbed object should be part of the core events, together with grab/place/release. I think it’s up to the developer to program what happens whenever any button, not just the trigger, is pressed while grabbing an object. I personally have used the trigger not only for weapons in video-game environments but also in simulation using a drill for example. What I normally do is create a component that uses the UxrGrabbableObject functionality to determine when it is being grabbed and then check for trigger input. This input can then be used to play audio, animations, etc.

I guess that what you developed tries to simplify the user of the trigger button when an object is being grabbed, and additionally play audio, but this is too specific to be part of the core functionality. What I think would be a great addition is to expand your idea and consider “triggering” to press any non-grab button whenever an object:

  1. Is being grabbed.
  2. Is within grabbable range.

It’s up to the developer to check the event parameters and see whether the triggered object is not being grabbed, being triggered with the grabbing hand, or being triggered with the non-grabbing hand. This would also require additional parameters on the UxrAudioManipulation inspector trigger event to determine when the selected audio needs to be played:

  • bool _triggerWhenFree
  • bool _triggerWhenGrabbingHand
  • bool _triggerWhenNonGrabbingHand

In addition to UxrAudioManipulation, UxrManipulationHapticFeedback would also require support for the trigger event.

What do you think?

entromp avatar Aug 02 '22 12:08 entromp