Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

336
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda