Search Unity

Unity XR Interaction Toolkit, XRController > Device is invalid

Discussion in 'XR Interaction Toolkit and Input' started by STEMax, Jun 21, 2020.

  1. STEMax

    STEMax

    Joined:
    Jun 18, 2018
    Posts:
    13
    Hi Guys,

    I'm trying to setup the XR Interaction Toolkit in a sample scene, and try to interact when the user push the thumbstick to the left or right. However I'm not able to achieve that. I'm using a piece of code from the VR Tutorial (that is using the Legacy Input System) and update it for XR Toolkit, here is the interesting part:

    Code (CSharp):
    1. InputFeatureUsage<Vector2> feature = CommonUsages.primary2DAxis;
    2. for(int i = 0; i < _controllers.Count; i++)
    3. {
    4.     XRController controller = _controllers[i];
    5.     if(controller != null && controller.enableInputActions)
    6.     {
    7.         InputDevice device = controller.inputDevice;
    8.  
    9.         Vector2 currentState;
    10.         if(device.TryGetFeatureValue(feature, out currentState))
    11.         {
    The call to method "TryGetFeatureValue" is returning false, and if I look at the device object it is in state "invalid". Is there a way to act on the thumbstick move with the XR Interaction Toolkit, what I only see for now is example for grab object.

    STEMax
     
  2. a436t4ataf

    a436t4ataf

    Joined:
    May 19, 2013
    Posts:
    1,933
    Your code is broken if you cannot get a valid InputDevice.

    Stop using the old tutorial, build this yourself in a new project - it will be very very quick to do - and then compare the two projects and figure out why the InputDevice is broken in your old tutorial project.

    My guess is that you haven't installed / configure the new Unity XR / XRIT properly, and so it's failing to startup. Or maybe you're trying to use legacy and XR at the same time, and causing them to conflict. But the best thing to do is make a new project and check you've got XR working first, and know how to make it work reliably.
     
  3. STEMax

    STEMax

    Joined:
    Jun 18, 2018
    Posts:
    13
    Hi a436t4ataf,

    Thanks for your reply, indeed this has been added to a new project, I took this idea from the tutorial, but the code has been created directly in a new project. I'm not sure I did try the GrabInteract exemple on this specific project, so I will retry and see. It was working on another project for sure (the GrabInteract) but it does not use this device property.

    STEMax