Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

323
Views
SteamVR: Correct way to get the input device triggered by an action and then get it's corresponding Hand class?

I have an action that is mapped to both my left amd right hand triggers on my VR controllers. I would like to access these instances...

Player.instance.rightHand 
Player.instance.leftHand

...depending on which trigger is used but I can't fathom the proper way to do it from the SteamVR API. So far the closest I have gotten is this...

public SteamVR_Action_Boolean CubeNavigation_Position;

private void Update()
{
    if (CubeNavigation_Position[SteamVR_Input_Sources.Any].state) {

        // this returns an enum which can be converted to string for LeftHand or RightHand
        SteamVR_Input_Sources inputSource = CubeNavigation_Position[SteamVR_Input_Sources.Any].activeDevice; 
    } 
}

...am I supposed to do multiple if statements for SteamVR_Input_Sources.LeftHand and SteamVR_Input_Sources.RightHand? That doesn't seem correct.

I just want to get the input device that triggered the action and then access it using Player.instance.

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

I was also looking for an answer to this. I've for now done what I think is what you mean with the if-statements. It works, but definitely not ideal. You want to directly refer to the hand which triggered the action, right?

With the 'inputHand' variable here I get the transform.position of the hand from which I will raycast and show a visible line. I could have put a separate instance of a raycastScript like this on each hand, of course, but I wanted to make a 'global' script, if that makes sense.

private SteamVR_Input_Sources inputSource = SteamVR_Input_Sources.Any; //which controller
public SteamVR_Action_Boolean raycastTrigger; // action-button
private Hand inputHand;

private void Update()
{
    if (raycastTrigger.stateDown && !isRaycasting) // If holding down trigger
    {
        isRaycasting = true;
        inputHand = inputChecker();
    }
    if (raycastTrigger.stateUp && isRaycasting)
    {
        isRaycasting = false;
    }
}

private Hand inputChecker()
{
    if (raycastTrigger.activeDevice == SteamVR_Input_Sources.RightHand)
    {
        inputHand = Player.instance.rightHand;
    }
    else if (raycastTrigger.activeDevice == SteamVR_Input_Sources.LeftHand)
    {
        inputHand = Player.instance.leftHand;
    }
    return inputHand;
}
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!