Search Unity

Question Get float value from Quest 2 grip button

Discussion in 'Input System' started by PascalTheDog, Oct 16, 2021.

  1. PascalTheDog

    PascalTheDog

    Joined:
    Mar 16, 2015
    Posts:
    86
    Hey,

    I'm working in VR with the Oculus Quest 2, using the XR toolkit and trying to animate a rigged model's hands using input actions.

    Technically, it works. The hand is open when the grip isn't pressed and the hand is clenched when it is... but I can't get the hand to show any of the intermediate stages. The thing is, the grip button is more like a conventional gamepad bumper than a button; it should be expressed as a float (0 to 1) rather than as a bool (true or false) unlike its default behavior in the toolkit, right? So I changed the associated Input Action's action and control types to Value and Axis respectively, and read its value as a float in code.

    However, for some reason, it will only output 1 (pressed) or 0 (not pressed) with no in-between. It's a float all right, but pretty much acting as a bool; in fact, I suspect it's just a bool being converted to a float at some point.

    How can I get the Quest 2 gamepad grip button to output a usable float value? Assistance would be greatly appreciated. Cheers!
     
  2. Judgeking

    Judgeking

    Joined:
    Apr 15, 2017
    Posts:
    17
    - Select the XRI Default Input Actions project item the XR Input Action Manager is using, then Edit Asset
    - select the left or right hand Interaction, then the Select action for Grip or Activate action for Trigger values
    - change Action Type to Value and Control Type to Axis
    - under the Trigger or Grip bindng path, change from triggerPressed or gripPressed to just trigger or grip
    - click Save Asset when done
     
    Last edited: Jul 7, 2023
  3. brianisbrilliant

    brianisbrilliant

    Joined:
    Sep 30, 2019
    Posts:
    1
    @Judgeking Thanks for that! I haven't messed with the new input system hardly at all. If I can offer a follow-up question, is there a way to get the XR Grab Interactable > Interactable Events to interpret activate as a float? Or to add another event for "OnValueChange"?