Correctly handling both mouse and stick input.

I realized that I've been misusing mouse delta input for a while now. Since it's an absolute value, it should not be scaled by deltaTime when determining how much to move the camera. This contrasts with the relative value of a gamepad's stick.

If you multiply the mouse input by deltaTime, you wind up making your view sensitivity framerate-dependent. oops!

The solution I worked out has been to check if the active control is a mouse...

        latestLook = lookAction.action.ReadValue<Vector2>();

        if (lookAction.action.activeControl != null)
            if (lookAction.action.activeControl.device.description.deviceClass == "Mouse")
                latestLook /= 60;
                latestLook *= Time.deltaTime;

This is kind of fiddly. Does the Input System have a way to abstract this away, so that the value of the action is always an absolute amount of movement?

Giving this a bump, since I ran into someone having this problem on the forum recently (:

I think this would be straightforward if I could check if a particular control is a delta or not. I guess I could just directly check for "Delta" in the control path?

Ah, I just found this post , which suggests using a processor. That's exactly what I needed here! I've written custom processors before, but didn't think of it for this case...

1 Like