Delta [Mouse] is triggering InputActionPhase.Started and Canceled constantly?

Setup (UnityEvents):

 public void OnRotationInputBegan (CallbackContext _context)
    {
        Vector2 _rotationInput = _context.action.ReadValue<Vector2> ();
        switch (_context.phase)
        {
            case InputActionPhase.Started:
                Debug.Log ("Started");
            break;
            case InputActionPhase.Canceled:
                Debug.Log ("Canceled");
            break;
        }
    }

With ActionType being a Button (WASD, Run Button, Jump Button) there’s no issue, InputActionPhase.Started triggers at key press and InputActionPhase.Canceled at release, 1 time only.

But when the ActionType is a value (Vector2 _rotationInput) Started and Canceled are being triggered continuosly each frame while the value is changing. It is not behaving as a “start” and an “end” like key presses.

What’s going on?

This is an artifact of how the delta controls operate. Deltas are somewhat “special” in that they accumulate within frames and then reset at the beginning of the next frame. So, say you have two mouse motions in the first frame and then another in the next frame. You’ll get

Frame 1:
  (deltaX1, deltaY1)
  (deltaX2+deltaX1, deltaY2+deltaY1)
Frame 2:
  (0, 0)
  (deltaX3, deltaY3)
Frame 3:
  (0, 0)

Thus the unusual pattern of how the actions fire.

1 Like