Mouse Help

Okay, so I want to parent ObjectA to ObjectB. ObjectB is moving wherever the mouse is. I found this script:

import Rasterizer as r
import GameLogic as g
c = g.getCurrentController()
o = c.getOwner()
mouse = c.getSensor("mouse")
move = c.getActuator("move")
wx = r.getWindowWidth()/2
wy = r.getWindowHeight()/2
mx = mouse.getXPosition()
my = mouse.getYPosition()
x = 0.005

Now the only problem is that it only works for top view (because it is only x and y axis. Is there a way to change this to X and Z position? Z being up and down and X being left and right?

I tried mouse.getZposition but soon after I found out this is not a command.


I think it’s just to get the position on the screen. Search for andrew’s mouse tutorial.

instead of




basically you take the x and y inputs from the mouse (which only returns the x and y positions on the screen), and plug them into whatever output you want; in this case, the x and z DLOC inputs (which are in 3d space). Careful if the object is physics enabled though, DLOC doesn’t mix with physics.

by the by, using ‘x’ as a multiplier might get confusing when working with an x,y,z coordinate system. Just a li’l tiperoo.

I did the searching for you, heres the tut B3D00 was talking about: