Mouselook, keep camera upright

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. :stuck_out_tongue:
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[0] * sensitivity
UD = move[1] * 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? :confused:

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 :stuck_out_tongue:

Thanks.

Let me update my last post…

First of all, I forgot to mention that it is in third-person view, which may matter.
Also, I found out that it rotates the camera when you move diagonally, not in circles.

Perhaps a video would be more clear:
Tim Sanders uploaded this video to

I’m stumped… :spin: