cancel
Showing results for 
Search instead for 
Did you mean: 

How to know left or right controller?

andrewThe_Great
Honored Guest
How do I know if the controller for my Oculus Go is Left or Right handed in Unity? Is there a simple command to put in an if statement like:

if (Controller is left) {

}
3 REPLIES 3

HeyBishop
Protege
Hi @imperativity,
It's important to me to be able to determine the handedness too.
For the Oculus Go, I have the following code:
Debug.Log("Is L connected: " + OVRInput.IsControllerConnected(OVRInput.Controller.LTrackedRemote));
Debug.Log("Is R connected: " + OVRInput.IsControllerConnected(OVRInput.Controller.RTrackedRemote));
At runtime (on the device) both lines return: "Is X connected: False".



So, what am I doing wrong? How does one determine which hand the user is using?

I got the above code from the following documentation:
https://developer.oculus.com/documentation/unity/latest/concepts/unity-ovrinput/#unity-ovrinput

HeyBishop
Protege
I just checked to see how it's done in the GearVrControllerTest scene provided. It would seem this function doesn't work here either. Was OVRInput.IsControllerConnected(OVRInput.Controller.LTrackedRemote) deprecated?

ucidqcr3ptfr.jpg

HeyBishop
Protege
OMG!
I figured it out!

 OVRPlugin.GetDominantHand();
It's an enum. With it, I created the following script:

public class UserHandedness : MonoBehaviour
{
public static UserHandedness Status { get; set; }

void Awake()
{
if (Status != null && Status != this)
{
Destroy(gameObject);
}
else
{
Status = this;
}
}

public bool IsRightie()
{
OVRPlugin.Handedness handedness = OVRPlugin.GetDominantHand();
if (handedness == OVRPlugin.Handedness.RightHanded)
{
return true;
} else
{
return false;
}
}

public bool IsLeftie()
{
OVRPlugin.Handedness handedness = OVRPlugin.GetDominantHand();
if (handedness == OVRPlugin.Handedness.LeftHanded)
{
return true;
}
else
{
return false;
}
}
}



With it, I can do this in any other script:

if (UserHandedness.Status.IsLeftie())
{
Debug.log("You're a southpaw, awesome!");
}