Input System delta[mouse] add values on click

Hi Im trying to make a first person controller with Character controller and the new input system. One problem appear in delta[mouse] or delta[pointer]is the the Vector2 returns a value when i press any button of the mouse, this cause that the player camera rotate a little bit. Example:


These are my actions:

And this is my code:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem;

[RequireComponent (typeof(CharacterController))]
public class PlayerCharacterController : MonoBehaviour
{
    private Vector2 moveInput = Vector2.zero;
    private Vector2 rotationInput = Vector2.zero;
    private float cameraVerticalAngle = 0f;
    // ****** Character Controler
    private CharacterController characterController;
    // ****** Input Actions
    private PlayerInputActions inputActions;

    [Header("Refrerences")]
    [Tooltip("Reference for the main camare used for the player")]
    public Camera playerCamera;

    [Header("General")]
    [SerializeField] private float walkSpeed = 12f;
    [SerializeField] private float gravityDownForce = 20f;

    [Header("Movement")]
    [SerializeField] private float speedOnGround;

    [Header("Rotation")]
    [SerializeField] private float rotationSpeed = 60f;

    [Header("Jump")]
    [SerializeField] private float jumpForce;

    private void Awake()
    {
        characterController = GetComponent<CharacterController>();
        inputActions = new PlayerInputActions();
        inputActions.PlayerControlls.Move.performed += ctx => moveInput = ctx.ReadValue<Vector2>();
        inputActions.PlayerControlls.CameraMove.performed += ctx => rotationInput = ctx.ReadValue<Vector2>();
    }

    private void Start()
    {
        //Cursor.lockState = CursorLockMode.Locked;
    }

    private void Update()
    {
        Move(inputActions.PlayerControlls.Move.ReadValue<Vector2>());
        Look(inputActions.PlayerControlls.CameraMove.ReadValue<Vector2>());
    }

    private void Move(Vector2 direction)
    {
        if (direction.sqrMagnitude < 0.05)
            return;
        float scaledMoveSpeed = walkSpeed * Time.deltaTime;
        Vector3 move = Quaternion.Euler(0, transform.eulerAngles.y, 0) * new Vector3(direction.x, 0, direction.y);
        transform.position += move * scaledMoveSpeed;
    }

    private void Look(Vector2 rotate)
    {
        if (rotationInput.sqrMagnitude < 0.05)
            return;

        // ****** Limit the X rotation force amount
        rotate.x = Mathf.Clamp(rotate.x, -10f, 10f);
        rotate.y = Mathf.Clamp(rotate.y, -10f, 10f);

        // ****** Delta rotation in Quaternions
        rotationInput.x = rotate.x * rotationSpeed * Time.deltaTime;
        rotationInput.y = rotate.y * rotationSpeed * Time.deltaTime;

        // ****** Vertical rotation in degrees
        cameraVerticalAngle += rotationInput.y;
        cameraVerticalAngle = Mathf.Clamp(cameraVerticalAngle, -70f,70f);

        transform.Rotate(0, rotationInput.x, 0);
        playerCamera.transform.localRotation = Quaternion.Euler(-cameraVerticalAngle, 0f, 0f);
    }


    private void OnEnable()
    {
        inputActions.Enable();
    }

    private void OnDisable()
    {
        inputActions.Disable();
    }
}
1 Like

I have the same issue. Looks like a bug.

I don't even see Mouse Delta as an Option...

2 Likes


Ran into same issue but it looks like the Action Type has to be Pass Through for the delta option (and others like position) to pop up.

I have the same issue as @antony_morar and @MakMiles .

I wanted to include a very simple reproduction case and hopefully get a member of the Unity dev team to provide some input.

I've also got this video which demonstrates the issue.


The amount of drift and direction is actually somewhat random and intermittent, and sometimes you need to wiggle the mouse around or look in a different direction before it happens.

But from the point in the video where you see the Vector2(-7, 0) being logged in the console, this is being caused by me clicking.

You can check in the code in the attached project but to be clear, the console logs relate to the mouse delta values from the input system, I don't log Vector2.zero and only log values that are different from the last value.

What this means is the console logs are demonstrating that the mouse isn't actually moving (if it were there'd be logs every frame with different values) and the simple action of clicking is registering a mouse delta value.

If it helps the video is taken on a MacBook Pro running macOS 11 and the built-in touchpad. I haven't had the opportunity to test with Windows 10 yet.

This is with Unity 2020.3.15f2 and Input System 1.0.2.

7388579--901922--unity-input-system-bug-main.zip (29.6 KB)

Hello
I do have the exact same issue as of Unity 2020.3.33f1 ...
I can't continue my game anymore as this destroyed my entire camera system ... please anyone fix this....

Opened my own thread and submitted a bug report. Hopefully we get an answer ...
Link to the new thread: https://discussions.unity.com/t/878347
Video as well there

1 Like