Search Unity

Resolved OpenXR with Input System - no LeftHand primary2DAxis

Discussion in 'XR Interaction Toolkit and Input' started by HeyBishop, Jan 7, 2021.

  1. HeyBishop

    HeyBishop

    Joined:
    Jun 22, 2017
    Posts:
    238
    I cannot get the Unity Input System to recognize the joystick on the left XR controller.

    I have a third person character with a simple controller script, and I'm attempting to control it with either the lefthand or righthand controller's primary 2D Axis joystick/thumbstick. I'm using an Oculus Quest via Link (it seems to be connected fine).

    Using the sample controller schemes, I got it working mostly well. The character successfully moves if the user inputs with a gamepad, keyboard, or with the joystick on the right hand XR controller. It will not work with the primary2DAxis Left XR Controller. I've tried every path option: primary2DAxis, secondary2DAxis, thumbstick, joystick with no luck.

    Interestingly, the Jump Action works fine if the user presses the primaryButton on either controller, as desired. If you look at the screen capture below you'll see my action map, with Jump having several bindings, all successful. For Move, all the bindings except for the LeftHand XR Controller works.


    upload_2021-1-7_15-54-26.png

    Unity 2020.2.1f1
    XR Interaction Toolkit (0.10.0)
    OpenXR Plugin (0.1.2)
    Input System (1.1.0)
    Oculus Quest 1
     
  2. HeyBishop

    HeyBishop

    Joined:
    Jun 22, 2017
    Posts:
    238
    Also - I should mention that when I use the [Listen] feature uPath, it does 'hear' the LeftHand thumbstick.

    upload_2021-1-7_20-25-48.png

    Interestingly, when I Listen for the right controller, it'll 'hear' that one too. But the result of that doesn't work when selected. It only works if I manually choose the right controller via the menu.
     
  3. HeyBishop

    HeyBishop

    Joined:
    Jun 22, 2017
    Posts:
    238
    Hi there - just bumping this thread. Hoping someone might be able to shed some light on this issue.

    Thank you.
     
  4. Matt_D_work

    Matt_D_work

    Unity Technologies

    Joined:
    Nov 30, 2016
    Posts:
    202
    Please put a bug in for that one!
    you could also try
    <XRController>{LeftHand}/thumbstick
    as the binding and see if that works.
     
  5. kittik

    kittik

    Joined:
    Mar 6, 2015
    Posts:
    565
    It sounds like you could be be using SteamVR.

    I have found that when using a Quest 1 with Link cable with SteamVR, the joystick doesn't register in 2020.2. To change your runtime provider, go to Project Settings > XR Plug-in Management > OpenXR. Select Oculus from the dropdown.

    Of course, presently if you want to build your project and publish it, any future users who default to SteamVR would face the same problem when using a Quest 1 and link cable..

    Please let me know if that works for you. As you eluded to in another thread, I think there are several bugs atm, which is really hampering me too. :(
     
    Last edited: Jan 12, 2021
  6. HeyBishop

    HeyBishop

    Joined:
    Jun 22, 2017
    Posts:
    238
    I've submitted a bug report.
    As I was putting it together, I discovered another curiosity.

    When a Debug.Log command is added to my public void Move(InputAction.CallbackContext context) function, it still displays activity, though no movement. When the Quest is active, the keyboard stops working (though the Debug logs this too). When the Quest is not active, the other inputs work fine (a Logitech gamepad and a keyboard).

    I've demonstrated these new curiosities here:
     
  7. the_real_apoxol

    the_real_apoxol

    Unity Technologies

    Joined:
    Dec 18, 2020
    Posts:
    467
    After looking through your submitted bug and project it looks like the issue is with the PlayerInput script. The PlayerInput script is designed to handle multiple players and it is treating each controller as a separate player and they end up fighting each other (which is why the input gets choppy). For VR the PlayerInput script will probably get in your way more than help you, instead you can reference the action directly within your `SimpleThirdPersonChar` script and everything works as you intended. The following fixes the issue in your project.

    1) Remove the player input script
    2) Add the following code to the `SimpleThirdPersonChar` script

    Code (CSharp):
    1.    
    2. public InputActionReference moveAction = null;
    3.  
    4. private void Awake()
    5. {
    6.     controller = GetComponent<CharacterController>();
    7.     moveAction.action.Enable();
    8.     moveAction.action.performed += Move;
    9. }
    3) In the inspector set the `moveAction` field to the `Player/Move` action

    Hopefully that helps.
     
  8. HeyBishop

    HeyBishop

    Joined:
    Jun 22, 2017
    Posts:
    238
    This is great!
    Thank you so much.
    It is so much more elegant than what I was doing.

    For others, I'll share my revised script:
    Code (CSharp):
    1. using UnityEngine;
    2. using UnityEngine.InputSystem;
    3.  
    4. public class SimpleActionInputSystem : MonoBehaviour
    5. {
    6.     Vector2 moveDirection;
    7.     CharacterController     controller;
    8.     public InputActionReference moveAction = null;
    9.     public InputActionReference jumpAction = null;
    10.  
    11.     private void Awake()
    12.     {
    13.         controller = GetComponent<CharacterController>();
    14.         moveAction.action.performed += Move;
    15.         jumpAction.action.performed += cxt => Jump();
    16.  
    17.     }
    18.  
    19.     void Update()
    20.     {
    21.         control.SimpleMove(moveDirection);    
    22.     }
    23.  
    24.     public void Move(InputAction.CallbackContext context)
    25.     {
    26.         moveDirection = context.ReadValue<Vector2>();
    27.     }
    28.  
    29.     public void Jump()
    30.     {
    31.         Debug.Log("Jump");
    32.         // do jump stuff
    33.     }
    34.  
    35.     private void OnEnable()
    36.     {
    37.         moveAction.action.Enable();
    38.         jumpAction.action.Enable();
    39.     }
    40.  
    41.     private void OnDisable()
    42.     {
    43.         moveAction.action.Disable();
    44.         jumpAction.action.Disable();
    45.     }
    46. }
     
    RaphaelChevasson likes this.