Hey guys, need a bit of help…
I’ve got the basis for a “rolling marble” type game…
I just got my mouselook script working, but it’s got one small problem that I can’t seem to fix.
If you move the mouse in a circle a bunch, the camera will start to rotate along the (local) Z axis. Obviously, I don’t want this, since the camera shouldn’t be sideways.
Here’s my script:
import GameLogic as GL import Rasterizer as R cont = GL.getCurrentController() own = cont.getOwner() mouse = cont.getSensor("MouseMove") updown = cont.getActuator("updown") leftright = cont.getActuator("leftright") screenw = R.getWindowWidth() screenh = R.getWindowHeight() sensitivity = 0.0008 def mousemove(): x = mouse.getXPosition() - screenw/2 y = mouse.getYPosition() - screenh/2 if own.MouseStart == False: x = 0 y = 0 own.MouseStart = True return (x, y) move = mousemove() LR = move * sensitivity UD = move * sensitivity leftright.setDRot(0, 0, -LR, False) updown.setDRot(-UD, 0, 0, True) GL.addActiveActuator(leftright, True) GL.addActiveActuator(updown, True) R.setMousePosition(screenw/2, screenh/2)
I’ve tried fixing it with constraints, (Limit Rotation, Track To, and Locked Track,) but none of them seemed to work. I think Blender must ignore them since the Python script is telling it to do something else?
Anyway, how should I fix this? Is there something I can add to my script to make it lock the rotation on the camera’s Z axis?
The answer is probably really simple, but I cant figure it out. lol