Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question No "state" set for SteamVR controller actions

Discussion in 'XR Interaction Toolkit and Input' started by rwblodgett, Jan 14, 2021.

  1. rwblodgett

    rwblodgett

    Joined:
    Apr 4, 2017
    Posts:
    66
    Hi I'm using 2019.4.18 with the SteamVR plugin and Oculus. I have Oculus working with the XR framework and UI interactions, buttons, clicking works.

    SteamVR I recognize I have to add "actions" to get it to work with the UI.

    I have a script that gets references to the actions like this:

    Code (CSharp):
    1. private Valve.VR.SteamVR_Action_Boolean triggerAction = Valve.VR.SteamVR_Input.GetAction<Valve.VR.SteamVR_Action_Boolean>("Trigger");
    2.         private Valve.VR.SteamVR_Action_Boolean gripAction = Valve.VR.SteamVR_Input.GetAction<Valve.VR.SteamVR_Action_Boolean>("Grip");
    3.         private Valve.VR.SteamVR_Action_Boolean menuAction = Valve.VR.SteamVR_Input.GetAction<Valve.VR.SteamVR_Action_Boolean>("Menu");
    4.         private Valve.VR.SteamVR_Action_Vector2 axis2dAction = Valve.VR.SteamVR_Input.GetAction<Valve.VR.SteamVR_Action_Vector2>("Axis2D");
    And I try to grab the state of the action in Update:

    Code (CSharp):
    1. bool state = triggerAction.GetState(Valve.VR.SteamVR_Input_Sources.RightHand);
    but state is always false.

    I have an action set activated with the "Trigger" action. This used to work, but has broken by some update. I have to enable both the Legacy and New input systems in the Player settings otherwise I get that infuriating dialog when 2019 starts.

    Any ideas why the boolean "state" variable is always false?
     
  2. rwblodgett

    rwblodgett

    Joined:
    Apr 4, 2017
    Posts:
    66
    Follow up. When I create a build, steamvr actions work fine. Only in the Editor are things screwed up.
     
  3. TreyK-47

    TreyK-47

    Unity Technologies

    Joined:
    Oct 22, 2019
    Posts:
    1,816