Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Mouse Delta Input Not Registering

Discussion in 'Input System' started by Local-Man, Feb 17, 2020.

  1. Local-Man

    Local-Man

    Joined:
    Jun 19, 2018
    Posts:
    1
    I'm trying to shift my project from the old unity input system to the new one and came across an issue with moving the camera using the mouse. Initially i used Input.GetAxis("Mouse X") etc but now I'm using Delta Mouse. However, whenever I move my mouse my vector2 variable _lookAxis prints out (0,0).

    Here's The code i used:

    Code (CSharp):
    1.     private Vector2 _lookAxis;
    2.  
    3.     void Awake ()
    4.     {
    5.         controls = new PlayerControls();
    6.  
    7.         Setup();
    8.     }
    9.  
    10.     void OnEnable()
    11.     {
    12.         controls.Gameplay.Camera.performed += HandleCameraInput;
    13.  
    14.         controls.Gameplay.Enable();
    15.  
    16.     }
    17.  
    18.     void OnDisable()
    19.     {
    20.         controls.Gameplay.Camera.performed -= HandleCameraInput;
    21.  
    22.         controls.Gameplay.Disable();
    23.  
    24.     }
    25.  
    26.     private void HandleCameraInput(InputAction.CallbackContext context)
    27.     {
    28.         if (context.performed) {
    29.             _lookAxis = context.ReadValue<Vector2>();
    30.             Debug.Log(_lookAxis);
    31.         }
    32.     }
    33.  
     
  2. Tomobodo

    Tomobodo

    Joined:
    Dec 31, 2012
    Posts:
    7
    Same issue here, setting a vector2 action with delta or position doesn't trigger anything.
     
  3. Jichaels

    Jichaels

    Joined:
    Dec 27, 2018
    Posts:
    237
    For inputs that have a value every frame, I'd go with polling in an Update.
    Can you show how your action is set up in the action asset ?