# What is the geometrical interpretation of Input.GetAxis("Mouse X")?

According to the documentation, Input.GetAxis("Mouse X") produces a range of values from -1 to 1. However it will produce another range if it is setup to be delta mouse movement.

Returns the value of the virtual axis identified by axisName.

The value will be in the range -1...1 for keyboard and joystick input. If the axis is setup to be delta mouse movement, the mouse delta is multiplied by the axis sensitivity and the range is not -1...1.

# Question

I don't understand what the value means geometrically. Is it a displacement between two points each in consecutive frame updates? If so what is its unit? Pixels, points, centimeters, etc?

This is something you can determine empirically. Drop in a script like this:

public class MouseDeltaCheck : MonoBehaviour
{
public Vector2 screenPos;
public Vector2 positionDelta;
public Vector2 inputDelta;
public Vector2 ratio;

void Update() {
Vector2 newScreenPos = Input.mousePosition;

positionDelta = newScreenPos - screenPos;

inputDelta = new Vector2(Input.GetAxis("Mouse X"), Input.GetAxis("Mouse Y"));

if(inputDelta.x != 0f)
ratio.x = positionDelta.x / inputDelta.x;
if (inputDelta.y != 0f)
ratio.y = positionDelta.y / inputDelta.y;

screenPos = newScreenPos;
}
}


In my experiments, the mouse delta value is approximately:

{Change in Pixel Position} * {Axis Sensitivity} / ({OS Scaling Factor} * 2)


Where {Axis Sensitivity} is the sensitivity value you've configured for the "Mouse X" and "Mouse Y" axes in the Input Manager, and the {OS Scaling Factor} is any scaling being applied outside the game (for instance, in Windows 10 Display Settings, I usually run my Surface with the "Scale and Layout" setting at its recommended value of 150% so text is a readable size on the high-resolution display).

I say "approximately" because there is some variance - likely due to the Unity deltas being summed from several hardware event deltas that might include fractions of a pixel, while the absolute position value is necessarily rounded to a whole pixel coordinate prior to scaling being applied. This variation is small and bounded - even when accumulating deltas over many frames spanning movement all over the screen, I never found the two measures of travel disagreed by more than 1.5 pixels (1.5x being my OS scaling factor at the moment).

I don't know what accounts for the * 2 multiplier though.

• How did you empirically derive the formula {Change in Pixel Position} * {Axis Sensitivity} * {OS Scaling Factor} * 2 ? Commented Jul 16, 2019 at 10:56
• Whoops, answered this in the wee hours of the morning and accidentally flipped my ratio upside down. The last two multiplies should be divisions (corrected in an edit). So when the axis sensitivity is 1 and the OS scaling factor is 1.5, I get a ratio of 3 (1 / (1 / 1.5 * 3)). Changing the OS scaling factor to 1, I get a ratio of 2 (1 / (1 / 1 * 2)) Commented Jul 16, 2019 at 13:34
• The longer I press the key, the greater value GetAxis(). It return 0 if I don't press. What is the physical interpretation of this? Commented Jul 17, 2019 at 19:35
• You said you were using "Mouse X" — that's not a key. If you want answers about using GetAxis to read keyboard input, ask a new question. Commented Jul 17, 2019 at 19:41