Firstly, is this 2.49 or 2.57
Looking at the script it looks 2.49
Several things:
Don’t bother learning the 2.49 python, as it changed in 2.57
I suspect you are actually trying to use a 2.49 script in 2.57, and that is one reason it is not working.
Anyway I will go an with how to do it in 2.57:
In 2.57 it is very different. The first two lines are replaced with:
import bge #Tells blender it is a script for the game engine
cont = bge.logic.getCurrentController() #Replaces the cont line
own = cont.owner #Replaces the Own Line
your next three lines of actual code don’t make much sense.
While you would have seen no errors, this is because you define everything, but don’t tell it what to do.
So what you wrote actually says forward is this sensor.
You never actually tell it to do something with it.
The reason for this is that you have to define everything before you can use it.
To define things you go:
forward = cont.sensors["W"]
motion = actuators["motion"]
speed = 1
You also need to divide up the actuator so that python knows what’s what:
linX, linY, linZ = lin_Speed
Then set all of them to 0 by default:
linX = 0
linY = 0
linZ = 0
So you got that nearly right, just the change in python from 2.49 caught you out.
Now that you have defined everything you have to tell it what to do with these things.
So you can go:
if W == true:
linY = Speed
You also need to define how much force the actuator is going to be able to add:
servo.forceLimitX = [-100,100,True]
servo.forceLimitY = [-100,100,True]
servo.forceLimitZ = [-100,100,True]
Now is another part you missed, activating the motion.
A simple enough line:
lin_Speed = linX, linY, linZ
motion.linV = lin_Speed
cont.activate(motion)
you just put the three values back into the actuator
For this to work you will need the actuator to be of type “servo motion”
Now if I have got everything right it should work.
Feel free to ask questions it I didn’t explain enough