Search Unity

Question Converting existing VR project to Unity 2020.3 + OpenXR + New Input System + Vive (SteamVR)

Discussion in 'XR Interaction Toolkit and Input' started by PhaserLockEd, Jul 21, 2021.

  1. PhaserLockEd

    PhaserLockEd

    Joined:
    May 11, 2019
    Posts:
    2
    I'm trying to get an existing VR project (started in Unity 2019,) working with Unity 2020.3 for the Vive + SteamVR using the new OpenXR system and new Input system. Oculus platforms work fine (using Oculus specific libraries and code path, we will not be using the new input system for Oculus HMDs since they're already 100% functional). Vive + SteamVR is not working.

    So far, I can't get the Vive to work in the editor at all. The HMD shows the correct image, but I don't get any tracking for the HMD or controllers and I don't get any input from the controllers.

    I can get the Vive wands and HMD tracking in builds (position and rotation), but can't get any input from the controllers to work even in builds.

    QUESTIONS:
    1. Why am I not getting any input from the Vive wands? What do I need to change to start getting input? Note, position and rotation are working in builds but no other input.
    2. Does the Vive / do other SteamVR systems work in the editor? i.e. Have I missed setting something up, or is it expected that they do not work at all in the editor?
    3. Why did controller position and rotation tracking stop working when I switched to a copy of the XRI Default Input Actions, but HMD tracking continued to work? More information below.

    I'm using Unity 2020.3.10f1, URP, Input System 1.0.2, Oculus XR Plugin 1.1.1, XR Interaction Toolkit 1.0.0-pre.4, XR Plugin management 2.0.7.

    Under ProjectSettings > Player, I have ActiveInputHandling set to Input System Package (New).

    Under Project Settings > XR Plug-in Management, I have Oculus, OpenVR Loader, and OpenXR checked.

    Under Project Settings > XR Plug-in Management > OpenXR > Features, I have HTC Vive Controller Profile, Microsoft Motion Controller Profile, Oculus Touch Controller Profile, and Valve Index Controller Profile checked.

    I tried duplicating XRI Default Input Actions as a starting point for a custom set of input actions for my project, but after doing that (and updating my InputActionManager and PlayerInput components to point to the new input actions object) my hands stopped tracking in builds and I still wasn't getting any input. The HMD continued to track correctly. I've gone back to using the default sample for now.

    I have added a new Action to the XRI Default Input Actions > XRI RightHand action map. The new action is called "TriggerValue", the ActionType = Value, the ControlType = Axis, the binding path is "<XRController>{RightHand}/trigger".

    On my VR rig (this is using an existing rig, not a new XR Rig):

    I have added an InputActionManager component to the top level, and added one ActionAsset to the list, pointing to the XRI Default Input Actions.

    I have added a TrackedPoseDriver (New Input System) component and CameraOffset component to my center eye object.

    On each hand, I have added an XRController (Action-based) component and PlayerInput component.
    The left hand PlayerInput component is set to: Actions = XRI Default Input Actions, Default Scheme = Generic XR Controller, Auto-Switch is checked, DefaultMap = XRI LeftHand, Behavior = Send Messages.
    The right hand PlayerInput component is set to: Actions = XRI Default Input Actions, Default Scheme = Generic XR Controller, Auto-Switch is checked, DefaultMap = XRI RightHand, Behavior = Invoke Unity Events.

    I have the left and right hands set up a little differently just so I can try multiple things at once when I make changes, since I have to make a build to test changes. I have only mapped one event on the right controller. It is the "TriggerValue" action, it is set to Editor And Runtime, and points to OpenXRController.OnTriggerValueChanged.

    public void OnTriggerValueChanged(UnityEngine.InputSystem.InputAction.CallbackContext context)
    {
    float triggerValue = context.ReadValue<float>();
    m_TriggerAxis.x = triggerValue;
    Debug.Log("OnTriggerValueChanged(), new value: "+ triggerValue);
    }

    For the left controller, I have:
    protected ActionBasedController ControllerType;
    void Start()
    {
    ControllerType = GetComponentInParent<ActionBasedController>();
    ControllerType.enableInputActions = true; // I don't think I need this, but input isn't working so it can't hurt to add it.
    }
    void Update()
    {
    if (IsLeftHand)
    {
    if (ControllerType.activateAction.action.ReadValue<bool>())
    m_TriggerAxis.x = 1;
    else
    m_TriggerAxis.x = 0;

    if (TempDebugOldTriggerValue != m_TriggerAxis.x)
    {
    Debug.Log("New Left OpenXRController trigger value: "+ m_TriggerAxis.x);
    }
    TempDebugOldTriggerValue = m_TriggerAxis.x;
    }
    }
     
    BradyLi22 likes this.
  2. TreyK-47

    TreyK-47

    Unity Technologies

    Joined:
    Oct 22, 2019
    Posts:
    1,822
    Vive & SteamVR support is handled by their teams respectively.

    For Vive, please share this on their developer forums and their teams will help.

    SteamVR, post your issues on their Github so their team can address.
     
  3. BradyLi22

    BradyLi22

    Joined:
    Mar 13, 2023
    Posts:
    1
    I'm having the same problem! Did you ever find a fix for this problem?
     
  4. Giantbean

    Giantbean

    Joined:
    Dec 13, 2012
    Posts:
    144
    I have seen this response from TreyK on multiple posts now. Why would openXR that is supposed to work for all headsets require Vive and SteamVR support but it seems Meta is supported here? OpenXR is supposed to make development for all devices simpler and ever since Unity went with OpenXR and dropped OpenVR and especialy in toolkit 2.3.2 it has been a pain in the butt to get anything other then meta headsets to work with Unity. If there are settings that need to be in place for the toolkit to work with different headsets please put that in the documentation otherwise your tool is not supporting the community and its a Unity issue not a Vive or Steam issue. Take ownership and stop passing the buck.