I want to orbit the camera using a script without centering the cursor. So I wrote this script:
import bge
# get this controller script
cont = bge.logic.getCurrentController()
# get sensor named MouseLook
mouse = cont.sensors['MouseLook']
mousePosX = mouse.position[0]
mousePosY = mouse.position[1]
# get old mouse coords
obj = cont.owner
if not 'mousePosOldX' in obj:
obj['mousePosOldX'] = 0
obj['mousePosOldY'] = 0
# velocity
velX = mousePosX-obj['mousePosOldX']
velY = mousePosY-obj['mousePosOldY']
# get the actuators
moveH = cont.actuators['MoveH']
moveV = cont.actuators['MoveV']
# apply movement
moveH.dRot = [0, 0, velX*10]
moveV.dRot = [velY*10, 0, 0]
print('velX: {0}, velY: {1}' .format(velX, velY))
# save old pos in obj properties
obj['mousePosOldX'] = mousePosX
obj['mousePosOldY'] = mousePosY
Using this setup:
-OrbitH
-OrbitV
+Camera
And this game logic:
Unfortunately, nothing moves! The script seems to work, because I get valid values in the console from the print. When I directly connect the Sensor to the actuator without the script, the movement is applied (of course just with these constant values, which I don't want). So script alone works, and the movement along works too, where is the bug?