Search Unity

Resolved How to get controller input without a grab interactable?

Discussion in 'XR Interaction Toolkit and Input' started by henymeny, Mar 5, 2021.

  1. henymeny

    henymeny

    Joined:
    Apr 19, 2014
    Posts:
    10
    I am using the XR Demo and I understand how the Llama bubble gun is working with the input events. I want to make use of this input events to read controller data without anything being grabbed. I managed to do so by accessing the controller directly (with InputDevice.TryGetFeatureValue...), but I wonder how can I make use of the input system to achieve this?
     
  2. henymeny

    henymeny

    Joined:
    Apr 19, 2014
    Posts:
    10
    Finally I managed to get what I wanted.

    I ended up using InputActionReference reference as a script parameter and then
    reference.action.ReadValue<float>().

    For anyone interested, I needed this because I wanted a single interface for XR controllers and Simulated controllers. Also I don't need to manage controller connect/disconnect this way. Then I wanted to access the trigger amount like I had when using TryGetFeatureValue with CommonUsages.trigger (note I use float above instead of bool), I figured the XR Demo "InputActionAsset" has generic XR mappings for triggerButton, I guess some controllers just have a button trigger and not analog. Anyhow, I added a new input for trigger and it works like a charm.

    DO NOT TRY USING Player Input component like I did before. It is very unstable and such a shame Unity removed JS and stuck with C#. anything throws a damn error and so oh so difficult to have dynamic calls, types... not to mention I have to specify the ReadValue type >_< every time