Mouse in Game Engine

Hi everyone
I want to create a first-person shooter game in Blender, but I don’t know how to create a python script that will let you rotate the view 360 degrees. I did a Google search but didnt find anything :frowning: Could someone help me? Thanks in advance :smiley:

I have like 4 mouse scripts, they are mostly the same

you could also look at the walkthrough template or even look for other people’s scripts here

Thanks that really helps :smiley:

i really like this script. However, when I tried to use it in my own game, even though everything seemed to be setup the same, the camera is rotated 90 degrees to the left. The character rotates left and right just fine, and the camera rotates up and down just fine, but it’s just looking in the wrong direction.

I played with the math a little bit, but haven’t been able to get it right. Any idea how to get the camera to rotate to face the correct direction?

quiet_core: that sounds strange

are you using the same types of objects as me? Objects have their axes aligned different from cameras, and that has caused me problems in making this script

it would probably be easier somewhat to just try and append the objects from that file

after reading your comment i checked it out again and notice that my x and y on my object are the opposite to yours. +x is forward and +y is to the left. where as your +y is forward. however, my camera is setup the same way as yours.

do you know how i can change the matricies so that i’m looking down the +x axis of my object with the camera.

the script in that .blend is a lot more simple than my other ones

each setorientation call simply uses an orientation matrix for rotation around a single axis.

sx and cx are the sine and cosine of the rotation around one axis [which I call x, but it doesn’t have to be], and sz and cz are the same for the other axis.

BTW, on in the tutorials section, there is the tutorial on the walkthrough demo. You can alter the included file to be like a FPS.

hey z3r0 d

I was wondering… if I’d want to make a fps… how would I use your mousescript…
I mean If I want my character to move…
I tried to add two empties, then the empty with the camera parented could only rotate up or down and the second empty only left or right…
What I wanted to do is that when I rotate my mouse that I could rotate the first empty in y direction and the second one in x direction… so I made a copy of the script… one empty had a script that’s y sensitivity was 0.0 and the other with x’s sensitivity 0.0… the picture went wacky…

it would be much easier to simply copy the objects into your file

I have motion in there, there are some important parts about the motion is done you should also look at when considering the logic setup

however, I’ve seen this weird bug with it that when working at different scales [even at that scale] you kind of bounce off of walls, you like push into it then get pushed back.