First Person Template: Obstacles, Crouching, Swimming, Inclines...

This template is based on simple physics and features:

  • Movement over small obstacles, terrain and inclines
  • Running, Walking
  • Jumping
  • Crouching
  • Swimming, Diving
  • Pulling up on objects

Swimming and crouching only have 1 speed. Jumping while crouching is deactivated. If you enter a waterarea, your character will automatically go into a crouchState,
therefore when leaving a waterarea you manually need to stand up again.
You can can change speed and jump settings in init.py. Be aware that you need the
additional cylinders “Small” and “Big” for standing/crouching somewhere in your level.

W - Forward
S - Backward
A - Strafe Left
D - Strafe Right
C - Crouch, Dive down
E - Pull up on objects
Space - Jump, Dive up
Shift - Run, Walk (Shift enables walking)

The file is available for 2.49 and 2.53 Beta and may work for later versions too. Since there is still room for improvement and optimization left you may adapt and modify this template for your own purpose without any restrictions. There are also some guidelines included on how to use this template when designing a level as well as some programming tips when trying to extend the template. If you have understood what I have done here you can apply this to any low level game engine which does not provide a first person handler out of the box.
I am however not working on this template anymore because of different reasons, some of them are the limitations of BGE (e.g. incomplete compound and collision set, forced usage of logic bricks, no particle editor, no special effects, no MultiHitRay, etc.). If you want to create game content you don’t want to work around lacking basics all the time.

Attachments


FP_Template249.blend (357 KB)FP_Template253.blend (547 KB)FP_Template254.blend (550 KB)

Dear darczol

First post… and you give us a “fps/mouse look” template that works on the terrible 2.5?!
I could kiss you!!!
Thank you, thank you for sharing!
Bye

hi i have a little question… how can i set the player start position if it is another tha 0.0.0.? btw it’s amazing template if i solve this you will be in credits of my game :stuck_out_tongue: :wink:

It is most likely because of the IPOs. I’ll have to look into it again.

edit: I have solved it on the 249 template, but not yet in the 2.53. In the 2.49 version I had to copy the “lift” IPO curves from LocX,Y,Z into dLocX,Y,Z . However there are no such options in the new F-Curve. If you remove the the lift-animation completely, you can at least put the playermodel where you want. Strangely enough the Camera F-curve does not seem to produce this behavior. Sorry, but I’m not sure how this can be solved without further help.

Both are fixed now in first post. The pull-up animation had to made relative. Was inconvenient though because copy & paste features didn’t seem to work in F-curve of 2.53 and I had to add each key position manually…

Unless, someone else has already made a mouselook script that works in 2.5…
But if there hasn’t then,

He’s done it! He has done it! :smiley:
He’s the one… He is the one that will defeat the robot army… ha ha, what?

lol, I like the template, very well done, reminds me of mirrors edge… I like it :smiley:
Thanks!

hi the update is working but i dont know how to set the friction on the ground… in my map is player acting like the simulation of ice cube :smiley: he is sliding from on place to another… i want to have the precision jumping but if the player is sliding like on the skates i cant aim where i want…

Generally you don’t need to apply very specific friction settings. You can find them in the “Materials” section in both versions (DYN Button in 249 and Physics tab in 253). If you want to jump on a moving ground (e.g. a moving train) however you need to apply at least a friction of 5 in order to walk on top of it without sliding away. If you have inclines you need to apply a friction depending on the angle. Be aware that Terrain has all kinds of angles, so you must choose what is probably best.

Sliding on ground is only prevented by a damping function which presses the player slightly on the ground for a short time as soon as you release a movement button. If it weren’t for that, the player would also slide in the demo file on the white grounds which only have a friction of 0.4. You could of course set new timer settings at line 207 in Movement.py and change GameLogic.dSwitch value to a higher one. However the longer this damping function is, the more likely microbouncing can happen afterwards.
Furthermore you need to make sure that the maximum amount of fps is set to the default of 60, because the damping function is framedependent.

You could of course completely remove the damping function and use higher friction values for default objects. This is however the point where deeper issues start… and the limitations of BGE eventually make you run up the wall. From my point of view BGE is more usable for Strategy Games than FPS projects. Most of the hints above btw. are written into the info file in the template.

:slight_smile:

oh thank you for that quick reply i’m trying it right now and it’s working! I spend a lot of time to solve this thing in other fps templates but i never tried it with materials :smiley: once more thank you!

eh… another question… when i start the game in blender it works fine… but if i create the executable i’m not able to walk… the cmd or linux terminal will print this:

Traceback (most recent call last):
File “Movement.py”, line 5, in <module>
ImportError: No module named Blender.Mathutils
Python script error from controller “cont#CONTR#1”:

I!m guessing that the python have no Blender.Mathutils module build in them. any suggestions to fix this?

FALSE ALARM :smiley:

you can figure this out by rewrite this:

from Blender.Mathutils import *

to this:

from Mathutils import *

can i use this in my game? my fps default is horrible :[

Cool,

added to wiki.blender.org

If only we all had your faith Morpheus… wait, wha??

Looks awesome nice work :slight_smile:

hey… i have a problem with the bottom sensor… i have some editing on my fps engine, but i’m no check the console… and now i have this problem:


Python script error from controller "cont#CONTR#1":
Traceback (most recent call last):
  File "Movement.py", line 36, in &lt;module&gt;
KeyError: 'requested item "bottom" does not exist'

i presume you know how to fix it bcs you know where is the bottom sensor bcs it’s not in logic brick…

This doesn’t work at all for me. I can’t even move around, any suggestions?

Yes!
I suggest that you should give us some more information about your problem!
Bye

I’ll add more information, myself…this 2.53 template version just don’t work in the new 2.54beta!
Some errors in the console:

Python script error from controller “cont1#CONTR#1”:
Traceback (most recent call last):
File “MouseLook.py”, line 261, in <module>
File “MouseLook.py”, line 24, in main
NameError: global name ‘GameLogic’ is not defined

The 2.5x series its just a pain!

love what you did, works perfect in 2.53
but now i have 2.54 and it will not move 1 bit
do you know what the problem is?

greetz

This looks promising. Constructive criticism:

  • Try to improve the water physics. The sine-based bobbing up and down is a bit sickening, and not very realistic.

  • Smoother acceleration?

  • Try adjusting your actuation methods. At the moment, the player wouldn’t be able to stand on a moving object, and that’s a fairly important ability. (Mind you, the first halo couldn’t do that, and it’s very successful- so I suppose it depends on your point of view)

That’s about all I have to suggest within the limits of the methods being used… kudos on the scriptwork.

Also, it actually crashed 2.54, for me. Worked in 2.49 tho’.