Mouse view...

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)

just open this script in the text-window, and dont forget its name, then, in the realtime-buttons of your camera,
add a always-sensor ->
python-controler (where you wirte the name of the script in) ->
the four directions as movements and link them each to the controler. they shuld have the same name like the ones in the script, here they are called “links, rechts, auf, ab”.
then press p and I hope you’ll be happy :smiley:

-No,no.This script must be attached in this way:
1)Select your camera
2)add a Mouse Movement Sensor
3)connect it with a Python Controller that handles the script name
4)add two float properties named x and y

P.S.This part is ok

just open this script in the text-window, and dont forget its name, then, in the realtime-buttons of your camera

Could someone post a working Blend File as an example. For some reason I cant get this script to work? Does the X Diff have to be indented?

Thanks NDNChief, Been away for a while, good to be back! :smiley:

-Try this link:

http://aromari.supereva.it/MouseTest.zip

-this is a little mor complicated example.It divides the horizontal move and the vertical move in order to avoid the complete rotation in vertical sense.

Thanks Ben for the example, for me, it helps to see how the logic bricks are set up also. I was able to duplicate a working file. Thanks again…

The NDN…

Actually the tips you posted here, I knew all them, but the ‘‘POINT’’
was that I wanted how you guys do this, When I did this the camera
rotated wrong a it was so slow when I pressed ‘P’ that it almost crashed.
It was just like the frame rate was very low.