Search Unity

VirtualMouseInput stickAction delta is always 0,0 every second update

Discussion in 'Input System' started by RodGreen, Sep 22, 2021.

  1. RodGreen

    RodGreen

    Joined:
    Jan 11, 2020
    Posts:
    13
    Latest version of the InputSystem 1.1.1 the stickAction of the VirtualMouseInput always returns 0,0 delta.

    Debugging looks like the OnAfterInputUpdate is called from the 'Dynamic' / 'Fixed' state update but then also called by a 'Editor' state update.
    In the 'Editor' state update the value is 0,0 - which causes the Virtual Mouse to reset.

    With Dynamic it looks like they are 1:1 Dynamic update to Editor update so the virtual mouse never moves.

    Would be good if Unity provided a better callback that included the state so we can 'ignore' the editor update callback. Or at the very least allow us to query the current InputSystem state so we can ignore if it's in 'Editor'.

    Because it's been made internal the only way to fix this is to copy the package internally and fix the internal scope limitation.

    Also as a note 'defaultUpdateType' doesn't make a lot of sense for member name that returns the 'currentUpdateType'??


    Below code fixes the issue.


    Code (CSharp):
    1. private void UpdateMotion()
    2.         {
    3.             if (m_VirtualMouse == null)
    4.                 return;
    5.             #if UNITY_EDITOR
    6.             if(UnityEngine.InputSystem.InputSystem.s_Manager.defaultUpdateType == InputUpdateType.Editor
    7.                 || UnityEngine.InputSystem.InputSystem.s_Manager.defaultUpdateType == InputUpdateType.None)
    8.                 return;
    9.             #endif
     
    Last edited: Sep 22, 2021