What does "Mouse X" and "Mouse Y" return in Unity?
Go into Edit -> Project Settings -> Input and check the settings for the Mouse X / Mouse Y axes.
The Type
should be "Mouse movement" by default, which means its "mouse delta"
Use Key / Mouse Button for any kind of buttons, Mouse Movement for mouse delta and scrollwheels, Joystick Axis for analog joystick axes and Window Movement for when the user shakes the window.
https://docs.unity3d.com/Manual/class-InputManager.html
Dims
Software developer & Machine Learning engineer C/C++/Java/C#/Python/Mathematica/MATLAB/Kotlin/R/PHP/JavaScript/SQL/HTML/ LinkedIn: http://www.linkedin.com/in/dimskraft Telegram: https://t.me/dims12 I prefer fishing rod over fish.
Updated on December 05, 2022Comments
-
Dims 18 days
I wrote the following update:
void Update () { if( Input.GetMouseButton(0) ) { if( !dragging ) { dragging = true; xDragStart = Input.GetAxis("Mouse X"); yDragStart = Input.GetAxis("Mouse Y"); } xDrag = Input.GetAxis("Mouse X"); yDrag = Input.GetAxis("Mouse Y"); DragValuesText.text = "x = " + xDrag + ", y = " + yDrag; } else { if( dragging ) { dragging = false; } } }
and made a
Text
UI to displayDragValuesText
. After this I found, that returned values are small while I am dragging and turn to zero if I stop the mouse. Looks like they return delta. But how can I be sure?In documentation I don't see it is definitely delta. It says it CAN be delta, but how to know or change this fact -- it is not said.
-
Dims over 4 yearsSo it is impossible to configure absolute values? What units these deltas are in?
-
Fredrik Widerberg over 4 yearsIm not sure what unit actually.. If you want to know the absolute changes in pixels i guess you could store Input.mousePosition on mousedown and check difference every frame