Search Unity

Question Open XR SendHapticImpulse working on Steam VR but not on Quest 2 standalone

Discussion in 'XR Interaction Toolkit and Input' started by Donion, May 24, 2022.

  1. Donion

    Donion

    Joined:
    Jun 7, 2017
    Posts:
    35
    As stated in the title I got haptics working using the new Open XR technique but for some reason it fails on the quest standalone.

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEngine.XR.OpenXR.Input;
    5. using UnityEngine.InputSystem;
    6.  
    7. enum Hand {
    8.     RIGHT,
    9.     LEFT
    10. }
    11.  
    12. public class HandHaptics : MonoBehaviour {
    13.     public InputActionReference rightHaptics;
    14.     public InputActionReference leftHaptics;
    15.  
    16.     [SerializeField]
    17.     Hand currentHand;
    18.  
    19.     private void OnCollisionEnter(Collision other) {
    20.         HapticImpulse(0.1f, 0.1f);
    21.     }
    22.  
    23.     public void HapticImpulse(float amplitude, float duration, float frequency = 0) {
    24.         if (frequency == 0)
    25.             OpenXRInput.SendHapticImpulse(currentHand == Hand.RIGHT ? rightHaptics : leftHaptics, amplitude, duration, currentHand == Hand.RIGHT ? UnityEngine.InputSystem.XR.XRController.rightHand : UnityEngine.InputSystem.XR.XRController.leftHand);
    26.         else
    27.             OpenXRInput.SendHapticImpulse(currentHand == Hand.RIGHT ? rightHaptics : leftHaptics, amplitude, frequency, duration, currentHand == Hand.RIGHT ? UnityEngine.InputSystem.XR.XRController.rightHand : UnityEngine.InputSystem.XR.XRController.leftHand);
    28.     }
    29.  
    30.     public void StopHapticImpulse() {
    31.         OpenXRInput.StopHaptics(currentHand == Hand.RIGHT ? rightHaptics : leftHaptics, currentHand ==          Hand.RIGHT ? UnityEngine.InputSystem.XR.XRController.rightHand : UnityEngine.InputSystem.XR.XRController.leftHand);
    32.     }
    33. }
    Im using Open XR version 1.3.1, Unity version 2021.3 and using the most recent input map for haptics.

    upload_2022-5-24_10-43-21.png

    Am I missing something?
     
  2. chris-massie

    chris-massie

    Unity Technologies

    Joined:
    Jun 23, 2020
    Posts:
    231
    I tested with 2021.3.1f1 and OpenXR Plugin 1.3.1 and it seemed to work fine. However, 0.1 amplitude and 0.1 duration is a very subtle vibration amount and it was much more noticeable with larger values. Can you try again with larger values to see if it works on Quest standalone?

    Can you also verify that the Haptic Input Action is enabled? If you are using the Controller sample from the OpenXR Plugin package, it should be doing that automatically with the Action Asset Enabler component on the PlayerRig GameObject.