Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice
  4. Dismiss Notice

Question UnityEngine.XR - Accessing Input Devices Not reading HTC Vive

Discussion in 'XR Interaction Toolkit and Input' started by jbvwxy18, May 3, 2021.

  1. jbvwxy18

    jbvwxy18

    Joined:
    Jul 29, 2018
    Posts:
    3
    I am using Open XR with an HTC vive. I am trying to access use the XR.InputDevices class to access the devices connected to the XR system I have setup per the documentation:
    https://docs.unity3d.com/2020.2/Documentation/Manual/xr_input.html#AccessingInputDevices

    However, when I follow this code, the debugger tells me that no devices can be found. I print out the number of devices and the result is zero.This is clearly not true since my headset and controllers work when playing the game:

    upload_2021-5-3_9-58-56.png

    any ideas as to why this doesn't return information about my vive?
     
  2. Rickmc3280

    Rickmc3280

    Joined:
    Jun 28, 2014
    Posts:
    187
    Not sure that you really want to go this route in 2020. Have you looked at resources regarding the new Input System?

    In my scripts I setup the

    InputDevice Helmet
    InputDevice LeftController
    InputDevice RightController and assign them through the use of nodes, using the same documentation that you provided in the link.

    Also in 2020, There are issues with Vive... it seems that you need to add the Pose Device script to those game objects. It seems that when you add the scripts they activate the controller, otherwise you cant read the data. I am not sure of your setup, but you would probably want to use the XR Rig. Also consider using 2019 as it still supports this method very well. 2020 not so much.
     
  3. jbvwxy18

    jbvwxy18

    Joined:
    Jul 29, 2018
    Posts:
    3
    HI,

    Thanks for getting back to me. I have been studying the new input system and it seems using a Vive is more trouble than its worth. I've been reading about some sort of dispute between Unity and Steam, and until that's resolved development with the Vive is going to suffer. I was thinking of switching over to an Oculus Rift as that seems to be more compatible with Unity's new input system.
     
  4. Rickmc3280

    Rickmc3280

    Joined:
    Jun 28, 2014
    Posts:
    187
    its actually fairly easy to work with. OpenXR is available to use in the package manager and the new Input system recognizes it when you set it up in the XR system... I used it this last week to update all of my old scripts that were polling and it is now mostly event driven. I think that a lot of how they go about it is pretty meh... but... Now I dont have to debate on staying in 2019 or updating to 2020. It all works... and it works better than it did before due to some changes that I made.

    Simply Create the InputAction, assign it in the inspector, set it as passthrough, (the cog icon), then Enable the action, and ReadValue<float>. good to go.

    Ex. InputAction myAction;
    myAction.Enable();//Start. Then you can use it. Dont forget to disable it.
     
  5. jbvwxy18

    jbvwxy18

    Joined:
    Jul 29, 2018
    Posts:
    3
    It's definitely something I have to play around with and learn more. I was able to manipulate object transforms and sizes using the input action.

    One last question, with the new XR system using a Vive, is the steamvr plugin still needed? Whenever I run a vr program, it is the steam vr plugin that turns on and tracks the movement. Is this stilll needed with the new system?

    How much stuff can I still use from the old steam vr assets? If I want to use the hand prefabs etc....
     
  6. Rickmc3280

    Rickmc3280

    Joined:
    Jun 28, 2014
    Posts:
    187
    That is a tricky question.

    I dont have SteamVR installed and it works just fine, however, it is using the instance from Steams OpenVr instance from what I gather(if you are using that). Supposedly it tries to find an instance of it(and you set that up also in the settings). The stuff you setup using Steam though will be pretty useless without a full rewrite. However, its nice having full control and it being adaptable. If you start your design with the index in mind, you have all the functionality pretty much, However design core features with the vive wand in mind and all extra availability will be index bound.