Input.GetAxis returns incorrect values

I’m having an issue with the rigidbody attached to my player controller. In the editor, everything works great. I play the scene and can move around without issue.

On the other hand, when I build the game my character starts moving immediately when the scene loads, and nothing can stop him. Moving in the opposite direction doesn’t counteract the movement, and setting rigidbody.velocity to 0 does nothing.

I can’t set the rigidbody to kinematic because I need to to collide with things in the scene.

Please help me out here, I’ve been trying to solve this for hours and haven’t gotten anywhere. Why would it work fine in the editor but suddenly break in the actual build? :rage:

The problem appears to be in this block of code:

if(Input.GetAxis("Oculus_GearVR_LThumbstickX") > 0.1f ||
   Input.GetAxis("Oculus_GearVR_LThumbstickY") > 0.1f ||
   Input.GetAxis("Oculus_GearVR_LThumbstickX") < -0.1f ||
   Input.GetAxis("Oculus_GearVR_LThumbstickY") < -0.1f)
{
       
    Vector3 dir = centerEyeAnchor.forward * Input.GetAxis("Oculus_GearVR_LThumbstickY") * movementSpeed;
    dir += centerEyeAnchor.transform.right * Input.GetAxis("Oculus_GearVR_LThumbstickX") * movementSpeed;

    dir.y = 0.0f;
    cameraObj.transform.position += dir;
}

Whenever I remove this code, I stop moving constantly. However, this also prevents me from moving at all, as this is the code that handles movement. :eyes:

Again, it works fine in the editor. It’s only in the actual build that something breaks…

Thanks for any help you can offer.

EDIT:

So, I did a bit of extra debugging, and it appears that Oculus_GearVR_LThumbstickX defaults to -1 when in the neutral position, and Oculus_GearVR_LThumbstickY defaults to 1, no matter how I move the joystick. Instead of the program reading it as being (0,0) when I’m not touching the joystick, it reads it as -1,1 regardless of how I move the joystick.

This is the source of the problem. Now, does anyone know how to fix this?

Oddly enough, those are the values that GetAxisRaw returns in the editor as well as built version.

Well, I’ve been able to circumvent the issue by pulling joystick data directly from the OVRInput class (OVRInput.Get(OVRInput.Axis2D.PrimaryThumbstick)), but I’d still really like to know why Unity’s Input system was returning the wrong cause.