how rotate an objet with the mouse

My question is very very basic. How I can rotate a 3d model with the mouse? I want to do something like the sebulba example, but I want to control with the mouse instead of the keyboard.

you can use a python script
Sensor (Mouse Movement) >> Python Script >> Motion Actuator
The Python Script

 
from GameLogic import *
from Rasterizer import *
Cont = getCurrentController()
Own = Cont.getOwner()
Sense = Cont.getSensor("sensor")
actTurn = Cont.getActuator("act")
 
Height = getWindowHeight()/2
Width = getWindowWidth()/2
XPos = Sense.getXPosition()
if (XPos-Width > 1):
     actTurn.setDRot(0,0,0.05,1)
     addActiveActuator(actTurn,1)
if (Width-XPos < 1):
    actTurn.setDRot(0,0,-0.05,1)
    addActiveActuator(actTurn,1)
     addActiveActuator(actTurn,0)
setMousePosition(Width,Height)

EDIT :
Yep ! Sorry ! Anyway i copied and pasted it from blender - but looks like i forgot to change the “sensor” name in one place
Anyway Captain has solved the problem. I just corrected it so that others may not get errors

I get lots of errors on your script, and I can’t fix the last few. Did you even test out this script before you posted it?

this script should work- the explanation of what to plug in is in the script


import Rasterizer as r
g=GameLogic
c=g.getCurrentController()
#there's one sensor, a mouse sensor named mouse, set to Movement
mouse=c.getSensor("mouse")
#there are 2 Motion actuators, named rotG and rotL (one for Local and the other for Global rotation)
rotL=c.getActuator("rotL")
rotG=c.getActuator("rotG")
#get cursor coordinates
mouseX=mouse.getXPosition()
mouseY=mouse.getYPosition()
#define center
midY=r.getWindowHeight()/2
midX=r.getWindowWidth()/2
#sensitivity
Xstep=0.005
Ystep=0.003
#set amount of X rotation
rotX=(midX-mouseX)*Xstep
rotG.setDRot(0.0,0.0,-rotX,0)
g.addActiveActuator(rotG,1)
#set amount of Y rotation
rotY=(midY-mouseY)*Ystep
rotL.setDRot(-rotY,0.0,0.0,1)
g.addActiveActuator(rotL,1)
#reset cursor position to center
r.setMousePosition(midX,midY)

Captain Oblivion you rock :slight_smile:

hi im wondeing if you can help, i want this exact script but it doesnt sem to work. could it be because im using the new version of blender? i set the script up on the object (cube) and change the names of the actuators ect but nothing happens when i run the game, please help

thanks