MouseMove - FPS Mouselook & Movement Script

Hey, if you guys copy/paste the code into your own blend file, you make sure to use Format > Convert Whitespaces > To spaces in the Text Editor, right? Sometimes the indentation of the code gets messed up when pasting from the clipboard, so that may cause the problem with the camera turning upside down. Try checking the console for error messages if it happens again.

Can you add a cap on the x axis, or a function to ā€œfreezeā€ the x axis?

I have a cutscene and the player must be able to turn his head (but not too much) on the x axis.

About the console, there are no error: only Blender Game Engine Started and Finished

A cap function for the X axis is pretty much freezing it. This can be done. Iā€™m currently working on fixing another bug so Iā€™ll add cap functions for the other axes after that. Sorry for the delay in the response :o

Update time! There are some major changes in the script, some involving changes to Property hooks. If you are using this script for either of the Movement systems, youā€™ll need to update your property names and values.

Changes:
:black_small_square: Fixed the camera flipping upside down (Thanks to SolarLune for help on this)
:black_small_square: Changed the names of the Location Movement properties
:black_small_square: Removed Force Movement and replaced it with the more realistic Dynamic Movement system

New Dynamic Movement Features:
:black_small_square: Player can only change directions when in contact with the ground
:black_small_square: Player can only jump (once) when in contact with the ground
:black_small_square: Player slides slightly after you stop moving
:black_small_square: Sneaking (Shift) makes the player slower
:black_small_square: Cannot jump while sneaking (or crouching, if you prefer to call it that)
Note: I forgot to include Shift in the Dynamic Movement control tips (in the instructions)

Latest Version
: 2.2 (8/28/11; 2:20pm)

Download:
MouseLook_Demo.blend

Alternate Download:

Thank you! Now my camera doesnā€™t go upside down.

Also, sorry for not being able to add in the cap for looking left and right. I think it would be too hard to determine which angle would be the initial angle and then limit rotation from that. What you could do instead is write a script to get the angle of that axis and when it reaches your own specified limits you can switch the mouselook scriptā€™s ā€œEnableā€ property to False.

Original Post updated with the Instructions Manual section. Instructions are also included with the script.

Hello Riyuzakisan,

Thanks for the awesome script!

I have a question: how would I go about changing the keys for wasd movement? Iā€™d prefer if they were the arrow keys instead, or better yet, configurable.

Thanks,
Ryan :slight_smile:

Thatā€™s a good idea, Iā€™ll see about adding in some configuration options for those. The simplest way is to have some presets, like WASD, IJKL, and Arrow Keys; Iā€™m not sure how else they could be easily defined by the user without running into some problems.

Hereā€™s a question for you about the custom movement controls. If you were using arrow keys for Location Movement, what keys would you use to fly up/down? They are normally E and Q.

Iā€™d say Q and A since theyā€™re easy to find without looking (on US keyboards at least).
Or maybe Insert and Delete which are very close to the arrow keys. That may not be the case at all for laptops though.

Q or A might work, I was also thinking of Z and X which might be better since theyā€™re laid out horizontally. Iā€™m guessing arrow key control would be easier for left handed users, but it kind of lacks those fly controls. What would be ideal for left handed users is probably the IJKL controls, then you have U and O for flying.

Hi im having a problem with this, when i use W it jumps and spacebar dont work ?
On your version it works perfect but on mine it dont :confused: please help

I see, this is because of the new movement system Iā€™ve added. I should add the ability to fly then.
I made the new movement system to be more realistic:
-The player canā€™t move forward while mid-air unless they were already moving before jumping
-The player canā€™t jump unless they are touching the ground

A fly option should fix this easily.

any way you can help me out mate ?

Not at the moment, itā€™s late. It would take a while to program in. You could try using the location movement system for the time if you want to fly around.

Nah i dont want to fly around, i just want to do what your fps does but on my own level and im having problems :>

So wait, W makes it jump, not space? I canā€™t help you there, it seems youā€™re having your own technical difficulties. Could you be clear on exactly whatā€™s going wrong again?

Yes when i press W it jumps, S and Spacebar do nothing, But in your file it works perfect.
I dont mind using your file but i have already made my level and would like to start again.
what difficulties would i be having ?

Open the Console window (Help > Toggle console) and type or paste a screenshot of any errors it might have. If it doesnā€™t have any errors, I have no idea whatā€™s going on. Iā€™ve copy/pasted my script into other blend files for use, and itā€™s worked fine.