Mouselook Cap

I’m quite new to Python, and i decided to make an FPS.
This is the code I use:

import GameLogic as gl
import Rasterizer as r
cont = gl.getCurrentController()
obj = cont.owner
parent = obj.parent
mouse = cont.sensors[‘Mouse’]
winh = r.getWindowHeight()
winw = r.getWindowWidth()

hwinh = winh//2
hwinw = winw//2
sens = 0.001

x, y = mouse.position
x = (hwinw - x)*sens
y = (hwinh - y)*sens

obj.applyRotation([y,0.0,0.0], True)
parent.applyRotation([0.0,0.0,x], False)


I want to implement a capping angle. How would I do so?

Thanks in advance!

here is a different mouse look by kevin over at wrectified - “TorqueMouse”

the object named “Center”

this uses Rigid body physics, and RBJ/6dof to constrain camera


TorqueFPS.blend (2.97 MB)

Thanks, but the reason I chose this script is because it is short and easier to study. How would I implement an angle cap?

Ok, you need to store a property, and if the value your adding is positive, it needs to be less then cap

AngleX = own[‘AngleX’]
AngleY = own[‘AngleY’]
if AngleX + mouseoffsetX > max:
________mouseOffsetX = 0
if AngleY + mouseoffsetY > max:
________mouseOffsetY = 0

and a negitive check as well, should be done with else?
if AngleX + mouseoffsetX < min:
________mouseOffsetX = 0
if AngleY + mouseoffsetY < min:
________mouseOffsetY = 0
or something similar?

I apologize, like I said I’m very new to Python and I have no idea how and where to put this, and what it all means…