Search Unity

How to use Vive controller trigger input

Discussion in 'VR' started by ckrogmeier, Jun 20, 2019.

  1. ckrogmeier

    ckrogmeier

    Joined:
    May 31, 2019
    Posts:
    4
    Hello,

    How can I use the trigger on the Vive controller to change material on an object in Unity?

    I already have the space bar set up to do this, but want to switch it to the vive trigger which actually changes the material.

    I have found various tutorials for vive controller input, but the scripting isn't recognized. I should be on the most updated version of Steam. I have put using Valve.VR at the top of the script.

    Specifically what is not recognized is the _default part of

    SteamVR_Input._default.inActions.GrabPinch.GetStateDown(SteamVR_Input_Sources.Any)

    Thanks,
    C
     
  2. PfudorMouli

    PfudorMouli

    Joined:
    Oct 13, 2015
    Posts:
    1
    Hi,

    Steamvr change the way you get the actions, but you can try it :

    Code (CSharp):
    1.  
    2.     private void Start()
    3.     {
    4.         SteamVR_Actions.default_GrabPinch.AddOnStateDownListener(TriggerPressed, SteamVR_Input_Sources.Any);
    5.     }
    6.  
    7.     private void TriggerPressed(SteamVR_Action_Boolean fromAction, SteamVR_Input_Sources fromSource)
    8.     {
    9.         //Do something
    10.     }
     
  3. ckrogmeier

    ckrogmeier

    Joined:
    May 31, 2019
    Posts:
    4
    thank you!