Ok, I don’t understand how to set this right. I don’t know how
to move camera with mouse movement, I have this python,
but I don’t know how to use it. I have tried almost everything
to apply it, but when I move the mouse then nothing happens.
from GameLogic import *
from Rasterizer import *
Cont = getCurrentController()
Own = Cont.getOwner()
Sens = Cont.getSensors()
Sensor = Sens[0]
Height = getWindowHeight()/2
Width = getWindowWidth()/2
get current mouse position
Xpos = Sensor.getXPosition()
Ypos = Sensor.getYPosition()
get actuators
RightMove = Cont.getActuator(“Rechts”)
LeftMove = Cont.getActuator(“Links”)
UpMove = Cont.getActuator(“Auf”)
DownMove = Cont.getActuator(“Ab”)
check positions relative to old position
Mouse going right
if (Xpos > Width):
# Move right
XDiff = Xpos - Width
RightMove.setDRot(0,0,(XDiff /Own.move),1)
addActiveActuator(RightMove,1)
Mouse going left
if (Xpos < Width):
# Move left
XDiff = Xpos - Width
LeftMove.setDRot(0,0,(XDiff/Own.move),1)
addActiveActuator(LeftMove,1)
Mouse going up
if (Ypos < Height):
# Move up
YDiff = Ypos - Height
UpMove.setDRot((YDiff/Own.move),0,0,1)
addActiveActuator(UpMove,1)
Mouse going down
if (Ypos > Height):
# Move down
YDiff = Ypos - Height
DownMove.setDRot((YDiff/Own.move),0,0,1)
addActiveActuator(DownMove,1)
Shut off all actuator movements
addActiveActuator(LeftMove,0)
addActiveActuator(DownMove,0)
addActiveActuator(RightMove,0)
addActiveActuator(UpMove,0)
Set the mouse to the center of the game screen
setMousePosition(Width,Height)