Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Input System: Correct bindings for Oculus controller 'thumbstick' input?

Discussion in 'AR/VR (XR) Discussion' started by moosefetcher, Feb 6, 2020.

  1. moosefetcher

    moosefetcher

    Joined:
    Sep 23, 2015
    Posts:
    74
    Hi there.
    I'm a couple days into trying to get the new Input System package working and I've got a few questions about the Input Actions menu.
    I am trying to use an Oculus controller's thumbstick to control movement.
    I've created a Input Actions Asset and named it 'Controls'.
    I've added an Action Map called 'Player'.
    In the Actions panel, I've added an action called 'Movement'.
    To this I've added a '2d Vector Composite' binding.
    For each of the Up, Down, Left and Right options in the action I've added bindings in the Properties panel, to XR Controller > XR Controller (LeftHand) > Optional Controls > joystick.

    Is any of this right? Is any of this wrong?

    I've also added a Movement script to my player GameObject, added a PlayerInput component and set that Actions object to the 'Controls' Input Actions Asset I've been describing above. Then I've also set Behaviour to 'Invoke Unity Events' and set up the Movement event (in the Events > Player dropdown) to the Movement.Move function. All on the advice of a couple YouTube tuts.

    With so many steps, it's impossible to know which part (or parts) is/are not correct.
    Any pointers much appreciated!
     
  2. moosefetcher

    moosefetcher

    Joined:
    Sep 23, 2015
    Posts:
    74
    Hi again.
    I've actually got it working with the WASD keys, so I'm hoping I've isolated the problem to the paths I'm using in the Action > Properties panel.

    Does anyone know what the correct path is (in the InputActions editor window) to listen for input from an Oculus touch thumbstick?

    Also, it looks to me like the 2019.3 documentation doesn't include the new Input System Package. Am I right in reading it that way?
    https://docs.unity3d.com/Manual/xr_input.html
    I will also continue the research.
     
    Last edited: Feb 7, 2020
    zonoscope likes this.
  3. Clavus

    Clavus

    Joined:
    Jun 6, 2014
    Posts:
    62
    I'm still exploring the new input system myself, but from what I can tell you shouldn't us the "2d Vector Composite". You should set the "Movement" input action to output a value of Vector2D, then add a simple input binding to the thumbstick. Now the Movement input binding should return the thumbstick axis output.
     
    zonoscope and Mickwa like this.
  4. moosefetcher

    moosefetcher

    Joined:
    Sep 23, 2015
    Posts:
    74
    Oh my god. That has finally worked!
    I swore I had tried everything. Thank you so much for the reply!
     
  5. ROBYER1

    ROBYER1

    Joined:
    Oct 9, 2015
    Posts:
    1,450
    If you try to use XR Interaction Package with this, everything breaks it seems.
     
  6. Mickwa

    Mickwa

    Joined:
    May 9, 2014
    Posts:
    15
    For me it worked with XR Interaction Toolkit (0.9.3 preview).
    It looks like to have events performed HMD must be put on, and focus on Game window must be set.
     
    ROBYER1 likes this.
  7. DanGxr

    DanGxr

    Joined:
    Dec 27, 2012
    Posts:
    9
    Thanks Clavus .

    I too have spent all afternoon trying to run with 2d Vector Composite.


    concise setup of Input System
    then swap out 2d Vector Composite Action to..

    Actions
    Action Type : Value
    Control Type: Vector 2
    AddBinding
    Properties: Binding: Path
    XR Controlller : thumbstick

    Allows me to translate object in Unity XR build with Touch joystick on Quest.
     
  8. abi17124

    abi17124

    Joined:
    Feb 16, 2020
    Posts:
    6

    This worked perfectly, thanks for the help!
     
  9. Matt_D_work

    Matt_D_work

    Unity Technologies

    Joined:
    Nov 30, 2016
    Posts:
    202
    they should work totally fine together, as the "Feature API" that we use actually peeks at the data stream which ends up in the new input system. if you've got more info on that we'd love to hear it.
     
  10. Holonautic_Nemanja

    Holonautic_Nemanja

    Joined:
    Nov 19, 2018
    Posts:
    2
    I'm trying to create an action and bind it to the trigger button on my Oculus Rift Touch controller. I tried setting the action to Button and also to Value/Axis, and for the binding I used: XR Controller -> Oculus Touch Controller -> Oculus Touch Controller (Right Hand) -> triggerPressed, and I tried playing with setting various interactions.

    I'm always getting the same thing: the "performed" event fires as soon as I make the slightest contact with the trigger button. Essentially, it's acting like triggerTouched, rather than waiting for me to fully press the trigger, as it should.

    I'm using serialized InputActionMap variables on a ScriptableObject as the place where my actions and bindings are defined. Bindings to simple buttons on the Touch controller (A, B, X, Y...) work normally.

    Am I doing something wrong or is this a bug?
     
    Last edited: Aug 18, 2020
    Butter_Bean likes this.
  11. WavyRancheros

    WavyRancheros

    Joined:
    Feb 5, 2013
    Posts:
    176
    I am having the same problem, it doesn't work for me.

    I have an Oculus Quest 1 controller, and a Vive controller. For both I got the trigger and the grip buttons to work.

    For the Vive controller, "primary2DAxis" works and gives me my Vector2.

    But for the Oculus Quest controller, nothing seems to work. I tried joystick, touchpad, trackpad, thumbstick, primary2Daxis, secondary2Daxis.

    thumstick [Right Hand Oculus Touch Controller] also does not work.

     
  12. WavyRancheros

    WavyRancheros

    Joined:
    Feb 5, 2013
    Posts:
    176
    I restarted the project, and now Primary2DAxis works on both Oculus and Vive. I wasted 4 hours on this.
     
  13. WavyRancheros

    WavyRancheros

    Joined:
    Feb 5, 2013
    Posts:
    176
    Now, Primary2DAxisClick does not work on either Oculus or Vive. I'm getting mad.

    *edit*
    PrimaryAxis2DClick does not work on Oculus or Vive controllers.

    This is the setup that works:

    trackpadClicked for Vive, and thumbstickClicked for Oculus.
     
    Last edited: Jan 28, 2021
  14. Ommageden

    Ommageden

    Joined:
    Sep 24, 2020
    Posts:
    7

    Exact same issue
     
  15. cutecenter

    cutecenter

    Joined:
    Nov 10, 2017
    Posts:
    2
    managed to get per axis working on Oculus Quest 2:

    1. Set Action Type to Value, Control Type to Stick
    upload_2021-3-5_16-18-11.png

    2. Then set path to below as shown
    upload_2021-3-5_16-18-58.png

    3. Edited code to output some values
    upload_2021-3-5_16-19-57.png

    4. Then assign the actions and test. (Remember to save input asset, or set to Auto-save)
    upload_2021-3-5_16-20-45.png

    Managed to get normalized output now from both axis.
     
    fatsneakybastrd likes this.
  16. NemesisWarlock

    NemesisWarlock

    Joined:
    Jan 21, 2017
    Posts:
    140
    You want triggerButton.
     
  17. henymeny

    henymeny

    Joined:
    Apr 19, 2014
    Posts:
    10
    This.

    also note action type Button didn't work well for me! I used action type pass-through and control type Button!
     
  18. keanine

    keanine

    Joined:
    Jul 27, 2013
    Posts:
    16
    After a lot of trial and error I got my thumbstickClicked working. I made a button action, added thumbstickClicked and ReadValue<float>(). It doesn't output bool values and .triggered doesn't get set to true. Hope that helps!
     
    joeysipos likes this.
  19. NarxGaming

    NarxGaming

    Joined:
    Mar 9, 2019
    Posts:
    7
    You can just use the regular input system, work with oculus in 2022.. i wrote a simple code that moves, strafes and turns. Just had to add an Axis as axis 4, I called it TurnStick.. then can move and strafe with left thumb and turn with right thumb...
    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;

    public class VR_CONTROLLER : MonoBehaviour
    {
    [SerializeField]
    float forwardSpeed;

    [SerializeField]
    float strafeSpeed;

    [SerializeField]
    float jumpHeight;

    [SerializeField]
    float turnSpeed;


    void FixedUpdate()
    {
    transform.Translate(Vector3.right * -forwardSpeed * Input.GetAxis("Vertical") * Time.deltaTime);

    transform.Translate(Vector3.forward * strafeSpeed * Input.GetAxis("Horizontal") * Time.deltaTime);

    transform.Rotate(Vector3.up * turnSpeed * Input.GetAxis("TurnStick") * Time.deltaTime);
    }
    }

    just adjust the speeds in unity inspector, used unitys basic vr project, put the script on the xr controller thang, had to invert some of the direction for some weird reasons? it works nice tho xx and sooo simple! I guess the buttons work similar.. not tried yet.. the Axis I added in edit/projectsettings/inputmanager was on axis 4.. that seems to be the Oculus right thumb stick.
    I expect that all the regular inputs like Fire1 and Fire2 etc work, its basically the same as a regular controller, although I know you can access it other ways as vr controller, my way works on keyboard, gamepads and vr controllers
     
    Last edited: Mar 9, 2022
  20. NarxGaming

    NarxGaming

    Joined:
    Mar 9, 2019
    Posts:
    7
    Not sure if you guys are over complicating things here? VR Controllers can be considered the same as regular ones and just use the in built Input system?
    you can map your Vr controller the same as a normal controller, most of the buttons will already correspond to gamepad buttons, so its just trial and error to find out which, the 4th axis seems to be the Oculus Right thumbstick, the left thumbstick works same as "Vertical" & "Horizontal" Axis on keyboard or gamepad. Will have a look at the touch sensitive buttons and get back with that..

    I gone and tried all the buttons on Oculus and mapped all but one to the already built in Input system.

    Left Oculus pad :

    Trigger = joystick 4
    ThumbStick Click = joystick 8
    ThumbStick Tilt = Vertical & Horizontal but one is flipped
    X = Fire3
    Y = Jump
    Sensor = joystick 12
    Menu = joystick 6
    Middle finger trigger ??????????

    Right Oculus pad :

    Trigger = joystick 15
    ThumbStick Click = joystick 9
    ThumbStick Tilt = 4th Axis
    A = Fire1 & Submit
    B = Fire2 & Cancel
    Sensor = joystick 11
    Middle finger trigger = joystick 5
    Menu = joystick 10 ??? not sure
     
    Last edited: Mar 9, 2022
  21. radiantboy

    radiantboy

    Joined:
    Nov 21, 2012
    Posts:
    1,633
    just tried this on my game, as if by magic most of it is mapped nicely. Even the triggers seem to be set up to turn you so long as you hold them down. Just wondering how to get the lasers that you see in oculus games.
     
  22. AudacityFilms

    AudacityFilms

    Joined:
    Jul 7, 2018
    Posts:
    6
    You're a GOD THANK YOUUU!!!
     
  23. binbbaz

    binbbaz

    Joined:
    Oct 20, 2022
    Posts:
    3
    I bought an asset configured to use the keyboard. DO you mean with some settings, I can change it to use input from oculus controllers? this is exactly what I've been looking for
     
  24. Shack_Man

    Shack_Man

    Joined:
    Jun 7, 2017
    Posts:
    372

    If the asset uses the new Input system then yes, it would be super easy to change that in the Input Asset without even touching the code.
     
  25. binbbaz

    binbbaz

    Joined:
    Oct 20, 2022
    Posts:
    3
    It's not actually using the new input system. That's why I'm finding it difficult. Can you help me?
     
  26. TimPham

    TimPham

    Joined:
    Sep 22, 2020
    Posts:
    5
    This works perfectly for me. Thanks a lot!
     
  27. joeysipos

    joeysipos

    Joined:
    Jul 28, 2015
    Posts:
    41
    Thanks! I can confirm. The thumbstickClicked returns a float value and not a Boolean on the Standalone Meta Quest. It Does return a Boolean on PC though... odd
     
    Last edited: Jun 26, 2023