Search Unity

How to Change Grab/Interact Button on SteamVR?

Discussion in 'AR/VR (XR) Discussion' started by FGPArthurVII, Jun 7, 2018.

  1. FGPArthurVII

    FGPArthurVII

    Joined:
    Jan 5, 2015
    Posts:
    68
    Using SteamVR for Oculus Rift, The standard button for grabbing an object is the frontal (or index) trigger, but since I am grabbing a Fire Extinguisher that I wish to eventually use the index trigger to "shoot" it to put out some fire. So I'd use the lateral (Hand) button (Grip) to keep holding it, and the trigger to Spray it instead.

    I already got the line to use the button in a general use (Equivalent to Input.GetKey(KeyCode.key)):

    Code (CSharp):
    1. if (device.GetPressDown(SteamVR_Controller.ButtonMask.Grip))
    2. {
    3.       //action
    4. }
    5. // If of course I am placing my hand on a Throwable Object
    But analising the "Throwable", "Interactable", and ''Hand" scripts I can't seem to find where would I replace it, in order to alter the Key, at all, The line doesn't even seem to be placed anywhere on the default code. Looking on the inspector where the scripts are attached, there is no field to change it either.

    How and Where can I Change the KeyCode?

    Thanks;
    Arthur.
     
  2. CasStr

    CasStr

    Joined:
    Jan 17, 2018
    Posts:
    1
    Old thread, but deserves an answer for the next reader. The grabbing action is called in Throwable.cs in several functions. The culprit is the call
    Code (CSharp):
    1. hand.GetStandardInteractionButtonDown()
    . The standard interaction button maps to the device trigger. A quick and dirty fix could be to replace that call with
    Code (CSharp):
    1. hand.controller.GetPress(Valve.VR.EVRButtonId.k_EButton_Grip)
    .
     
    Last edited: Oct 11, 2018
    poryjohn-z likes this.
unityunity