we often see questions like:
- how use mouse movment to aim up and down?
- Track to mouse position?
- mouse parent?
- Moving an object with mouse?
- mouse movement?
- Mouse look?
In a lot of this questions there is a lack of understanding what the mouse position is and how it belongs to a 3D scene.
The mouse is an input device.
There are several different device types e.g. Mouse, Trackball, Tablets, Touchscreen
They use different methods and are input devices. For simplification they are called mouse within this thread.
The mouse provides tracking information of at least 2 axis and some buttons.
The mouse resides usually on your desk. This makes it really hard for a game character to follow it.
Requests like: “move the object to the mouse” -> are are physical not possible ;).
I’m pretty sure this is more an issue of how to express the requirements :evilgrin:.
The user really meant: move the object to
The system mouse cursor
is the visual representation of the pointing device. It is a helper that shows the converted mouse position at the screen. By moving the (physical) mouse the position of the system mouse cursor changes.
Usually if someone talks about “mouse position” he means “position of the system mouse cursor on screen”.
The request is: “move the object to the position of the system mouse cursor”
Unfortunately this is still not specific enough.
The system mouse cursor lives in 2D space of the screen.
Our Scene is (virtually) 3D.
We need to convert the position of system mouse cursor to
A position in 3D scene space
If you (virtually) look from the side at your scene you can see under the system mouse cursor is not just a position. There is an unlimited number of positions. To be more specific: there is a line of positions.
You can pick any of them and you met your request.
The question is: which one?
This explains the next post …