XR Input: primary2DAxis always returns 0
Trying to use XR Input and working on joystick-based locomotion but trying to access the joystick always comes up 0. I'm using Oculus Rift Touch controllers (Not Rift S or Quest) and the devices and features needed are present.
Here's my code for reference: private List leftHands = new List(); private InputDevice rightHand;
private void Update()
{
// We get our hand(s) first before attempting to locomote
GetHands();
Locomotion();
}
private void GetHands()
{
InputDevices.GetDevicesAtXRNode(XRNode.LeftHand, leftHands);
}
private void Locomotion()
{
if (leftHands.Count == 0)
return;
if (!leftHands[0].isValid)
return;
Vector2 movementVector;
if (leftHands[0].TryGetFeatureValue(CommonUsages.primary2DAxis, out movementVector))
{
// Shows that value is always zero
print($"Left Joystick Values: {movementVector}");
if (Mathf.Abs(movementVector.x) >= 0.2f || Mathf.Abs(movementVector.y) >= 0.2f)
{
Move(movementVector);
}
}
}
Answer by ThatOwlGuy · May 07, 2020 at 04:07 PM
Ok... it turns out that it DOES work.
However... the inputs on a CV1 Oculus Rift Controller don't activate until the HMD senses that it's on your head.
Which... make sense(?) but will make debugging things more tedious.
Your answer
Follow this Question
Related Questions
XR Input: primary2DAxis always returns 0 1 Answer
Sending data to custom HID device 1 Answer
Problem using Oculus Touch Joystick Input to move XRRig 1 Answer
How do I create a Continuous Turn in XR for my VR Rig instead of Snap Turn Provider? 0 Answers
Unity Input and Oculus Rift with Touch Controllers in Unity 2018.3.7f1 1 Answer