Search Unity

Mouse delta input doesn't read null delta

Discussion in 'Input System' started by Fullspike, Nov 28, 2021.

  1. Fullspike

    Fullspike

    Joined:
    Aug 12, 2017
    Posts:
    11
    Hello
    I'm using input system 1.2.0 and I'm trying to read <Mouse>/delta as Vector2 through the player input in this way:
    upload_2021-11-28_16-11-13.png

    upload_2021-11-28_16-10-48.png

    the action is then mapped to a unity event "onLook" that reads the value:

    Code (CSharp):
    1.    
    2. public static void onLook(InputAction.CallbackContext context)
    3. {
    4.     rotateInput = context.ReadValue<Vector2>();
    5. }
    6.  
    However, the event is not called when the mouse stops while I expect it to read (0,0) value.
    It was working as expected with the 1.0.2 version.

    Where am I wrong?

    Thanks
     
  2. R1PFake

    R1PFake

    Joined:
    Aug 7, 2015
    Posts:
    542
    I noticed the same issue, did you find a solution?

    As a workaround I changed my script to call ReadValue every Update instead of using the event callbacks, this returns the correct 0,0 value. I hope the fix it in a new update.
     
    Last edited: Jan 14, 2022
  3. Chris-Trueman

    Chris-Trueman

    Joined:
    Oct 10, 2014
    Posts:
    1,261
    I am using the same version of the input system and get the expected behavior.
    Code (CSharp):
    1. public void LookAction(InputAction.CallbackContext ctx)
    2. {
    3.         if (ctx.canceled)
    4.         {
    5.             Debug.Log($"Stopped {ctx.ReadValue<Vector2>()}");
    6.         }
    7. }
    Console spits out Stopped (0.00, 0.00). when I stop moving the mouse.

    This is using the PlayerInput component using the UnityEvent.
     
  4. R1PFake

    R1PFake

    Joined:
    Aug 7, 2015
    Posts:
    542
    I checked again and even if I use the PlayerInput component it's the same behavior for me, which makes sense, because the PlayerInput class uses the same events internally.

    I added more debug logs and the "canceled" event, which would return the 0 values, does not get called at all in my case, which is weird, because the input debugger shows the change and shows the correct 0 values.

    I will make a new empty Unity project and send a bug report if it happens again. In the meantime I will continue with my ReadValue in Update workaround.

    Seems to be a rare issue, because I only found this thread about the topic or maybe the other posts used different terms, not sure.