get mouse coordinates

I want to get the 3d coordinates of my mouse.

if I use “position”:

g.mouseover = cont.sensors["mouse over"]     #mouse over any sensor
print (g.mouseover.position)

It gives me something like “[170, 490]”. These numbers seem to be associated with the x and y coordinates of my screen, not the actual 3d space.

if I use “hitPosition”:

g.mouseover = cont.sensors["mouse over"]     #mouse over any sensor
print (g.mouseover.hitPosition)

I get the correct x/y/z coordinates, but only when I mouse over the object that the sensor and script are attached to.

Use the hitPosition but with mouse over any.


Mouse over any and use the hitPostion in the script.
Sorry english :smiley:

I am using the “mouse over any” sensor. I just named it “mouse over”.

creating a plane in the background fixed the problem (I will probably need some background anyway). It would still be nice to know how to do this without something in the background.

then your Coordinate would need a max range, like a ray.

it would return “infinity,inifinity,infinity”

do you just want to use the mouse movement?

Attachments

TorqueMouse (2).blend (475 KB)

if you use the mouses moment to move the cursor object, and the mouse wheel to go up and down…

3d mouse :smiley:

note the sensitivity is high in this .blend because I use a touchpad

Attachments

MousePhysicsDemo (Current).blend (984 KB)