import bge
logic = bge.logic
mouse = logic.mouse
### CAMERA ###
def cam_orbit(cont):
own = cont.owner
scene = own.scene
target = scene.objects[own["target"]]
trackToTarget = cont.actuators["trackToTarget"]
trackToTarget.object = target
cont.activate(trackToTarget)
if not "oldCursorPosition" in own:
own["oldCursorPosition"] = [0.5, 0.5]
mouse.position = (0.5, 0.5)
x = (0.5 - mouse.position[0]) * own["sensitivity"]
y = (0.5 - mouse.position[1]) * own["sensitivity"]
deltaX = x
deltaY = y
target.applyRotation([-deltaY, 0, 0], True)
target.applyRotation([0, 0, deltaX], False)
mouse.position = (0.5, 0.5)
I’ve made this basic code. It’s supposed to work as mouse look orbit script. It works, but there is a massive problem. The object is rotating like if mouse was slightly down(e.g. like if it was 0.499), even though it’s at 0.5. I tried adjusting numbers up(like so: 0.50130519 or similar), but either the object kept rotating upwards, or started rotating downards, but it never stands still. What’s the reason of this issue and how to fix it?