Forum Discussion
to_the_cosmic_end
11 months agoProtege
How to send haptic feedback on UI hover/tap in Jetpack compose?
Hi, I am looking for a way to send small vibration as a haptic feedback on my 2D panel app whenever user hovers their raycast over a UI element, and stronger vibration when they tap on that element. ...
- 11 months ago
Hi! You can do this with the SpatialInterface.applyHapticFeedback() function.
// inside your AppSystemActivity somewhere // "spatial" is a SpatialInterface inherited from VrActivity // you can pass it around to somewhere else you need it reference it spatial.applyHapticFeedback( // hand: Apply haptics to the specified controller hand. Hand.RIGHT, // amplitude: Value between 0 - 1 for strength of haptics. 0.3f, // duration: Time in nanoseconds for how long the haptic feedback should be applied. (0.03 * 1e9).toLong(), // frequency`: Frequency of vibration (in hz). 128f )Hopefully this should help!
dav-s
11 months agoMeta Employee
Hi! You can do this with the SpatialInterface.applyHapticFeedback() function.
// inside your AppSystemActivity somewhere
// "spatial" is a SpatialInterface inherited from VrActivity
// you can pass it around to somewhere else you need it reference it
spatial.applyHapticFeedback(
// hand: Apply haptics to the specified controller hand.
Hand.RIGHT,
// amplitude: Value between 0 - 1 for strength of haptics.
0.3f,
// duration: Time in nanoseconds for how long the haptic feedback should be applied.
(0.03 * 1e9).toLong(),
// frequency`: Frequency of vibration (in hz).
128f
)
Hopefully this should help!
Quick Links
- Horizon Developer Support
- Quest User Forums
- Troubleshooting Forum for problems with a game or app
- Quest Support for problems with your device
Other Meta Support
Related Content
- 9 months ago
- 5 years ago
- 4 years ago