I has been looking for Mouselook for 2,5 alpha..

as ive search through web site and this forum for mouselook.txt
so far i only found zero…

i was used 2.49 and use this mouselook 2.49 at http://www.tutorial…MouseLook/

it wont working in 2.5 alpha.

please save my time… ive spend wasted my time search for this. is it exist? or not? do i have to go back rebuild on 2.49 ? because its working all fine. but i like 2.5 better. (iam going make huge map… will need 2.5 alpha which 2.49 dont has.)


Well, I made one script like this to 2.5x. Its very simple and works pretty well… It’s not commented but I think it’s not very difficult to understand the code.

import bge

cont = bge.logic.getCurrentController()
obj = cont.owner
mouse = cont.sensors['Mouse']

def DeltaMouse(Xcenter,Ycenter,lockToCenter=False,Xpos=mouse.position[0],Ypos=mouse.position[1]):#this function calculates the ditance (in pixels) of the mouse from two given points
    Dx = Xpos - Xcenter
    Dy = Ypos - Ycenter
    delta = [Dx,Dy]
    if lockToCenter and Dx or Dy:
    return delta

delta = DeltaMouse(int(bge.render.getWindowWidth()/2),int(bge.render.getWindowHeight()/2),True)
if obj['firstTime']:
    delta = [0,0]
    obj['firstTime'] = False
Hrot = delta[0] * obj['sens'] / -1000
Vrot = delta[1] * obj['sens'] / -1000

if obj['x']: obj.applyRotation([0,0,Hrot])
if obj['y']: obj.applyRotation([Vrot,0,0],True)

To work the scrip needs a set up like this:

-The logic bricks and properties have to be set to the camera
-The mouse sensor HAVE TO be called “Mouse” and don’t forget to change the “Mouse Event” to “Movement”

The properties:
“firstTime” - Have to be boolean and True. (Avoids a gap in the first movement of the camera)
“x” - Have to be boolean and allows or not the x axis movement
“y” - Same as “x” but for the y axis
“sens” - Can be float or integer controls the sensitivity of the movement (bigger means more sensitive)
-The names ARE case sensitive so they have to be written like in the image the and you have to set all this properties to the script work.

Well, thats all, I hope you like it :slight_smile:

what did i missed? its still no good.

I think there was a problem with mouse controls in the official 2.5 alpha release. You need to use a recent SVN build or wait for the upcoming 2.5x beta release. Recent SVN builds can be found at www.graphicall.org

can i use your script for made a french tutorial
for the HSR web site ??

Yeah sure, feel free to use as you want :slight_smile:

You didn’t set the prps to “True”. The “firstTime” prop have to be true and to move the camera “x” and/or “y” have to be “True”. And the “sens” prop should be bigger than 0. (negative values will produce inverted axis movement)

I’ll make a .blend example with commented code and post here later…:cool:

I’ve just tested in Alpha 2.52.0 and it doesn’t work, but in 2.52.5 (from GraphicAll.org) works nicely…

If the mouse looks like its drifting I think it’s because more recent builds return the mouse position as a normalised value, you need to multiply the mouse position by the window width and window height.

Yeah, this is the problem, maybe I write another version to work with 2.52.0. For now I’ve made a example file, I’m just waiting to be released in Blendswap.com than I post the link here…

aahh okay ill just use 2.49 for now. ill keep build in 2,5 then export to 2.49 (wihout animation keyframe! heh)

so i can has it ready for games as tester it will be a whiles! hah.

ill just wait for updated fixed for this. ill keep check this topic. as my environment need alots clear up to do anywhere.

finally the link is here.

… I LOVE YOU!!! haha its working! thank you very much… all i did link to your blend and use sciipt… and its work nice.


thanx dude! i’v been looking all night for this exact thing…