Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

329
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda