MouseMove - FPS Mouselook & Movement Script

I’m not entirely sure what you mean with the Empties/Spawners. The only empty in the .blend (mouselook demo file) that I posted was an empty in charge of toggling some mouselook features such as showing the Mouse Cursor. It wasn’t meant to be used to shoot, if that’s what you were thinking :stuck_out_tongue:

If you want to add a gun, parent it to the Camera, and then parent an empty to spawn bullets to the gun. This is up to you to set it up though. If you’re having trouble moving the player cube, post your .blend file and I’ll see what’s wrong with it.

Also, the parenting should look like this:
Gun (optional) --[parented to] --> Camera –[parented to]–> Player Cube

yeah its ok ive corrected it ^^
now ive got one problem (my last one)
i want my gun to animate
but after making the animation, setting the sensors and going into game mode its not moving -.-

Does your gun follow the camera when you look around? If so, that’s as far as I can help you here. If you’re having problems with getting the gun to animate, you’ll need to make a new thread about it in the BGE support & discussion section.

yeah its the problem that i cant get the gun to animate

its very funny
when ive solved one problem
the next problem is just waiting to happen xD

ive solved my problem that i couldnt animate the gun (just a mesh failure)
now when i press spacebar the player jumps
but when the player is in the air and i press again spacebar he just jumps again before he gets on the ground
so i can jump till i could touch the stars xP
its a pretty trick but i dont want it xD
why is that happening?

hey did what you said to do with dynamic movement…all it did was jump (sometimes) and that was it…location movement works fine though…blender 2.62 btw…so wats wrong any idea?

I cant seem to get it to work,

my blend: http://dl.dropbox.com/u/28372036/FPSmouselook%20WIP.blend

I followed your Dynamic movement tutorial, but it doesn’t work…?
I can look around and everything, just not move.

@suctioncup
Your Cube’s rotation was all messed up. The Mouselook script moves the cube on the local axes, so you need to apply its rotation values with Ctrl + A, otherwise the directions get all messed up.

  1. Parenting the Camera to the Cube would be a good idea.

  2. The properties go on the Camera object, not the cube. The “UseParent” property can be added and set to False to disable the Camera controlling the movement of the object it’s parented to. Either set the UseParent property to True if you have it added, or just delete that property if you don’t plan on using it.

Tip: The cube jumps pretty high, so if you add a “dJump” property, you can lessen that value. It’s at 10 by default.

@angbandguy1
Did you add Ray and Collision sensors on the player object and connect them to the Python controller on the Camera? Also enable True Pulse ([```] button) on the Keyboard sensor.

When I used this, Up and Down were inverted but Left and Right were not. I fixed it quickly by changing “self.move = (x, y)” into “self.move = (x, -y)”, but I’m sure theres a problem somewhere else with my setup :stuck_out_tongue:

It might be an issue with the object’s rotation values. I downloaded the original .blend and tested it in the latest version of blender, and I found that it works fine.

Hi Riyuzakisan, thank you for this script, but is there any chance you could dumb it right down to just rotating the player (the camera is parented to the player, but the camera does not rotate, the player does.)? I’m sure all it takes is a bit of erasing and maybe a line or two more, all I’m asking for is a very basic mouse-look, maybe with sensitivity though, please? Thank you.

I suppose it could be done by editing the code. What would the application be? If you’re just talking about using mouselook to control the player object itself, then you can attach the script to the player and not worry about it controlling the camera. If you’re just looking for a light weight script, then I suppose I could trim off some of the excess stuff and post it up here.

I’m having a problem getting the script to work. My camera looks around fine, but the movement isn’t working. I have Keyboard set as a sensor, True Pulse enabled, All Keys enabled, and I have the property of lMove-Boolean-True on the camera, but it still isn’t working.

I am using Blender 2.63, but I’m not sure if that is the problem.

Currently, the lMove part of the script only works on objects not parented to other objects, such as a free-flying static camera, otherwise it won’t work. Did you make sure that the camera isn’t parented to anything else? I’m not sure what else could be causing the problem.

Im having trouble getting the correct position for the camera based on games like MW3 or BC2 but thats the least of my problems. My main issue is trying to figure out how to make the arms and torso move up and down along with the script if thats even possible.

@dreprodigy: That sounds like it would most likely require another script altogether. If you’re talking about having the arms moving in 1st person mode, you can parent them to the camera. If you mean 3rd person mode, then that will definitely require another script to set the bone position in relation to the camera’s orientation.

The script works perfect in your .blend file!
But I have a problem in my file. I copied the script and configured it as written in the readme and also the dynamic moving. I parented the camera to the bone of my character. The mouselook works flawlessly but the movement got inverted (When I press W the character moves backward, and D key make him strafe to the left) and I can’t jump.

you sir, are awesome!

@PeperGhost: It sounds like a problem with the original rotation of the armature object. Try applying the rotation values to the armature by using Ctrl + A > Rotation (in object mode, not pose mode).

Hi :slight_smile:
First of all, amazing script.
I was trying to add a script that makes camera not to collide with walls. But I messed it all up :confused:
Do you have any solution for that?