Search Unity

Question How to access primaryButton new Input System with XR Interaction Toolkit?

Discussion in 'XR Interaction Toolkit and Input' started by Alixar, Feb 18, 2021.

  1. Alixar

    Alixar

    Joined:
    Mar 13, 2019
    Posts:
    50
    Very silly question, I have this default mapping:

    upload_2021-2-18_20-11-30.png

    to which I've added a primaryButton action. I found out I can access the trigger button like this:

    upload_2021-2-18_20-12-36.png

    Which is slightly different from what I'm used to outside VR (normally I would be accessing itvia: control.Activate.triggerPressed).

    How do I access the state of the primaryButton, to which event should I subscribe to read it?

    Thank you!
     
  2. Alixar

    Alixar

    Joined:
    Mar 13, 2019
    Posts:
    50
    Bumping this as I haven't yet found a solution :(
     
  3. chris-massie

    chris-massie

    Unity Technologies

    Joined:
    Jun 23, 2020
    Posts:
    231
    If you want to determine when the Activate action is triggered on the
    ActionBasedController
    , you can read that from the controller state that it maintains. Use the
    GetControllerState
    method on the
    ActionBasedController
    , and then from that you can obtain the input state for Select, Activate, and UI Press. For Activate, it's the
    XRControllerState.activateInteractionState
    field, and then you can read active to know whether it's triggered.
    active
    is true when the action is true, and
    activatedThisFrame
    will be true just on the frame where it was triggered.

    You can also read it from the InputAction that you have assigned to the Activate action reference directly. See the Input System documentation for Responding to Actions to either poll the value or to use events to get notified.