Some help regarding FPS Movement, Looking, and efficient real-time lighting

Hello Blender forum! I am working on an FPS game and I have run into some rather frustrating road-blocks:

  1. I am using forces for my movements. I read a tutorial that said to use Loc instead, but Loc is useless when going over uneven terrain (going downhill causes you to have seizures, stop go stop go, you get the picture). The issue with my Force movements is that it is unrealistic. It gives the effect of gliding on sticky ice. Increasing the friction just makes it harder to start walking and go uphill. As an important note, I have my Logic blocks set up so that I can only move and jump if I am "touch"ing another object.This way I cant fly. Is there any efficient way to set up motion so that it can deal with terrain yet appear realistic?
  2. I am using the script and setup from this tutorial: It works, however it does not constrain how far up and down you can look. What can I add to the file in order to make it stop going up/down once it has reached a certain verticle angle?
  3. I have enable GLSL for the BGE and I am using a spot lamp. For some reason, the light from the lamp shines through a door I have ingame and lights the floor BRIGHTLY no matter what angle I look at it. It is not textured or anything, and it only has a material. I even turned down the Spec and the problem persists. Will texturing it change this? (PS: The corridor beyond the door is made up of planes).
    Thanks for any help!

Look for another script that uses IPO instead of the motion actuator. Sorry, I can’t direct you to one (dunno). Rip it from Social’s FPS template?

Loc is the best option.

Alright thanks for that, I’ll try it. Any help on the other issues?

For the spotlight problem, did you tell it to use the “buffer shadow” method instead of the normal “ray shadows”? For normal (ie rendering) purposes, you should use “ray shadows”, but the BGE will only make “realtime shadows” if you use the “buffer shadows” method. Its under the lighting properties for the spotlight.

This mouselook script limits how far up you can look.

It also fixes the problem on Macs where the camera keeps rotating even when the mouse has stopped moving.

For the looking too far up problem:

Give the camera a property (I called mine “spine”).

Then change the script, so that it looks like this:

###################################################### Blender 2.46

Tutorial for using can be found at


import Rasterizer

import Rasterizer

get controller

controller = GameLogic.getCurrentController()

get the object this script is attached to

player = controller.getOwner()

Get sensor named Mouse

mouse = controller.getSensor(“Mouse”)

Get the actuators

lookLeftRight = controller.getActuator(“LookLeftRight”)
lookUpDown = controller.getActuator(“LookUpDown”)

get width and height of game window

width = Rasterizer.getWindowWidth()
height = Rasterizer.getWindowHeight()

define mouse movement function

def mouseMove():

distance moved from screen center

x = width/2 - mouse.getXPosition()
y = height/2 - mouse.getYPosition()

intialize mouse so it doesn’t jerk first time

if hasattr(player, ‘mouseInit’) == False:
x = 0
y = 0

bug in Add Property

can’t use True. Have to use 1

player.mouseInit = 1

return mouse movement

return (x, y)

get mouse movement from function

move = mouseMove()

set mouse sensitivity

sensitivity = 0.0005

Amount, direction and sensitivity

leftRight = move[0] * sensitivity
upDown = move[1] * sensitivity

keep from flipping out

if (player.spine > 1.3) and (upDown > 0):
upDown = 0
if (player.spine < -1.3) and (upDown < 0):
upDown = 0

set the values

lookLeftRight.setDRot( 0.0, 0.0, leftRight, False)
lookUpDown.setDRot( upDown, 0.0, 0.0, True)

Use them

GameLogic.addActiveActuator(lookLeftRight, True)
GameLogic.addActiveActuator(lookUpDown, True)

See how far player is bent

player.spine = player.spine + upDown

Center mouse in game window

Rasterizer.setMousePosition(width/2, height/2)

For some reason, the indents (that’s what you get when you press tab) don’t show here. You’ll need to figure it out yourself.

Have fun!

I’d also check that the material on the door isn’t set to super shiny or anything like that…

Allright thanks guys, I’ll try those (By the way, I know what an indent is hehe).

Better safe than sorry.

check here a FPS glsl demo/template:
you can use it as a start for your work

I tried what you said: I copied and overwrote my previous mouselook with yours, and I added an Int property to my camera with an initial value of 1. Now the camera doesn’t work at all. What am I missing here?

This area seems to be a trouble spot…

My FPS template might help you figure out the physics side of things. (Then again, it might not, ><) Hehe, FPS templates… they’re popping up like wild things.

    [ code ] [/ code ]

I think you need a float, not an integer.

There may be an indent missing.

The script I wrote relies on you naming certain things exactly as I did (such as properties and objects).

Perhaps you have an older version of Python.

Maybe I added extra spaces in the script I posted.

Maybe there’s a typo.

Perhaps this is just a miracle, or an otherwise unexplainable occurence.

Hi unknown_exe,

For the mouse look, have you taken a look at B3D00’s

capped mouse look?

Or the capped mouse look in Cray’s excellent

3rd person adventure template?


Simply amazing! I love your use of a “grapple beam”, and the dynamic view, and the random laser rebound. Just wow. You template may make a lot of things easier for me. I will change a lot of it though so I won’t be infringing. Thank you all for the help. One final question: I have a wall with a door that leads to a corridor (the wall is a plane). The normals can only face one direction, so one side is invisible. Is there any way to make a 2-sided wall without using a cube? Or is there some other way to have both sides visible that is commonplace in BGE games? Thanks again for any help!

Go to the Editing buttons, and give the mesh a UV Texture. Then go to the new tab “Texture Face” which only appears when it has said UV texture (!), select the faces to make double-sided, click the “Twosided” button in the Texture Face tab, then click the “Copy” button.

And, :smiley: I’d be honored if you used my template, not anti…infringe…ey. :confused:

Also, the rebound isn’t random… it occurs at angles below 10 degrees.

Haha thanks a lot. I’ll give you epic credit in the game (if it means anything ;)). And that is perfect for what I need! Normals are starting to tick me off haha. I may PM you some about your template if that’s all right with you? Thanks again!