(Unity XR) Left controller joystick Vector2 is set to zero in Void Update when right controller is on

Everything works fine except the value of my XR controller Vector2 joystick is set to zero in void update when my right controller is powered on. I’ve been working on this issue for way too long and there is literally no information about it online. I think it’s an overwriting issue caused by the right controller for no reason, combined with a syncing issue between Void OnMove and Void Update. I have no idea how to fix this, help.

Here’s the code

using UnityEngine;
using UnityEngine.InputSystem;

public class test : MonoBehaviour
{
    private Vector2 moveInput;

    public void OnMove(InputValue value)
    {   
        moveInput = value.Get<Vector2>(); // moveInput is working correctly
    }

    void Update()
    {   
        Debug.Log("move value in the void update: " + moveInput); // moveInput only work when my right xr controller is shut down
    }
}

Here’s my action map to prove that my right controller shouldn’t be affecting any of this.

So the joystick on the left resets to zero when the right controller is powered on?

If so, that might be a bug in Unity OR it might just be the nature of the driver for your controllers… it may consider all inputs (controller and head orientation and whatever else you have going) as a single “meta controller” and when its configuration changes, it resets everything.

Are you on a PC where you can test it in a control panel? Do you have other games that don’t do this?

Not really. In OnMove, the joystick value is correct even when the right controller is powered on, but as soon as the value is read in any other function like Update or FixedUpdate, it resets to zero. I’ve tried many workarounds and none of them worked. My last resort is to apply the force for my movement directly inside OnMove, but it makes the movement really choppy and unsatisfying. Other VR games I tested on my PC work perfectly fine. This makes absolutely no sense.

Show me the code that reads it along with the code above.

Also, put a Debug.Log() right in your OnMove call, see what’s getting written down.

If they’re in different classes, they are different variables, entirely unrelated.

I really doubt that looking into the movement script will help with the problem since it’s the same issue, just with the movement stuff, which makes it more complex. Anyway, here’s the full script.

using UnityEngine;
using UnityEngine.InputSystem;


public class vr_mouvement : MonoBehaviour
{
    private RaycastHit hit;
    private Vector2 moveInput;
    private Vector3 forward;
    private Vector3 right;

    public CapsuleCollider bodyCollider;
    public Transform mainCam;
    public Rigidbody XR_rb;
    public float speed;
    public float jumpForce;
    public float MaxHeightToJump;

    // movement
    public void OnMove(InputValue value)
    {   
        // input vector
        moveInput = value.Get<Vector2>();
    }

    void Update()
    {
        // cam vector
        forward = mainCam.forward;
        right = mainCam.right;

        forward.y = 0;
        right.y = 0;

        forward.Normalize();
        right.Normalize();

        // player vector
        Vector3 move = forward * moveInput.y + right * moveInput.x;

        if (IsGrounded())
        {
            XR_rb.AddForce(move * speed, ForceMode.Force);
            XR_rb.linearDamping = 3f;
            XR_rb.angularDamping = 0.5f;
        }
        else
        {
            XR_rb.AddForce(move * speed * 0.2f, ForceMode.Force);
            XR_rb.linearDamping = 0f;
            XR_rb.angularDamping = 0f;
        }
    }

    // jump
    void OnJump(InputValue jumpValue)
    {
        if (IsGrounded())
        {
            XR_rb.AddForce(Vector3.up * jumpForce, ForceMode.Impulse);
        }
    }

    bool IsGrounded()
    {
        Vector3 origine = transform.position + bodyCollider.center + Vector3.down * ((bodyCollider.height / 2) - bodyCollider.radius);
        float radius = bodyCollider.radius * 0.95F;

        return Physics.SphereCast(origine, radius, Vector3.down, out RaycastHit hitInfo, MaxHeightToJump, ~0, QueryTriggerInteraction.Ignore);
    }
}

Also, for the Debug.Log(moveInput) in the OnMove call always shows the good joysick input, it works properly all the time. It when it goes in void update() that moveInput become zero.

I’ve found a fix after a lot of debugging. It seems there’s an issue with the classic XR Input System joystick setup. In my case, the movement input wasn’t being detected correctly. To fix it, I imported the XRI (XR Interaction Toolkit) Starter Assets sample, which includes a properly configured Input Actions asset. After assigning and enabling those input actions, the joystick input started working correctly. If you’re having a similar issue where your movement values stay at zero or your controller input isn’t being recognized, importing the XRI sample is worth trying.