Proper FPS movement?

Hey guys. i’ve been working on this FPS project for awhile now. I’ve spent a large chunk of my time trying to get the movement to work correctly. It seems like there are a bunch of different ways you can achieve a typical FPS movement scheme in the BGE but every one of them seems to have relatively serious problems. I’m gonna try to list all the ones I’ve already tried here.

Simple motion - the “easiest” way. Just set up four simple motion actuators that correspond to your movement keys and you get seemingly normal FPS movement. Until you try to move your character up a ramp or any kind of surface that isn’t completely flat. The character will have trouble navigating the ramp and will usually fall through the floor when attemping to do so. The character often manages to walk through walls as well.

Servo motion, no friction - The aforementioned problem is easily solved by changing the motion actuators to “servo motion” and limiting the x axis movement to 0 when moving forward and backward and limiting y axis movement when moving side to side. This creates a new problem - when you let go of a movement key your character keeps moving due to inertia and a lack of friction to stop it. The apparent solution?

Servo motion with friction - add materials to your player and level objects and go to the DYN option under materials (I think its called DYN? if not its something very close those three letters). set the friction up a little bit on both objects. Now when you play your game your character will stop moving almost as soon as you let go of the movement keys. however you’ll also notice that there is no more sliding collision. If you walk into a wall at an angle you simply stop moving instead of moving parallell to the wall at a speed derived from the angle at which you are hitting the wall. Also, dependingo n how high you set the friction numbers, you won’t be able to walk up inclines steeper tahn a particular angle. Usually setting the friction high enough to get the player to stop reasonably quick also makes it so you can only walk up surfaces of the slightest angle.

That brings me to where I’m at now. I’ll call it “modified” servo motion w/o friction. Its basically the same as the first servo motion without friction I mentioned but with the addition of servo actuators that set your velocity along the y axis to zero when you aren’t moving forward or backward, and your x axis velocity to zero when you aren’t moving left or right. This comes pretty close to working like an FPS should. You can walk up inclined surfaces. you can slide along walls. The problems are that:

  1. if you walk into a wall for more than a split second, then, while continuing to hold forward (or whichever direcion you are going) you walk past a corner so you are no longer walking into the wall, you will shoot forward at a ridiculous speed.

  2. whenever you stop moving completely (that is, you were just holding down at least one movement key but are no longer holding any of them down) the character slides the opposite direction of the last movement key pressed ever so slightly. It is a pretty slight problem but for somebody who wants to get their FPS movement RIGHT its still pretty damn annoying.

Has anyone found a movement scheme that works the way it should?

The best method is to use python- if you don’t know it already, you probably shouldn’t be making anything more complex than breakout, there are tons of tutorials, learn it.

…If you use force, via object.applyImpulse (for instantaneous velocity changes) or object.applyForce(for changes to velocity that are applied after the script has finished).
To ensure the player doesn’t accumulate too much speed, if the object is going too fast in the X+Y directions set the velocity (in just the X and Y directions, to allow proper motion on sloped and other vertically-changing situations) to whatever top speed you want.
You can directly set the velocity, but I prefer to use force+capped speed, simply because the controls feel a LOT more natural if the player goes up to speed, instead of instantly moving top speed (even if this acceleration happens very quickly, it’s important)

Additionally, using python allows customizable controls, which are a necessity for any game with an even slightly involved control scheme.


Yes, I’m using python but I think in a somewhat primitive way. I’m still relying heavily on logic bricks, just using python to define how they work and reduce the number of sensors I need to use. Tutorials on using python for more direct control of the game world (as in mostly bypassing logic bricks) seem non-existent.

have you tried using servos? I usually use servors to fix these kinds of problems. And for the wall thing, make sure your gun (or character, but I only ever use the gun) has bounds.

Theres a simple way to fix your problems. Have a servo when you’re not pressing moment buttons to stop moving.

I attached an example.


motion example.blend (145 KB)

Nice one Excalaberr,

I do the same thingy, work pretty well :slight_smile: