Problems with using a script to control a servo controller

For the past week or so I have been trying to learn how to use the Blender game engine. I have recently come across a problem that has completely baffled me. I am trying to use python to control a Servo Controller actuator which is, for the moment, moving a cube around. However, the servo controller seems to be acting very differently when I make, what I believe to be the same commands through the scripting as opposed to simple logic bricks. Does anybody know why? bellow is my code and attached is my blend file. The second servo controller is the one that I want to imitate with scripts, except with modifiable speed.

Thanks in advance,

Note: Try to ignore the odd wording of the comments, I was bored :smiley:

# #############Variable Declartions

# Monotonous Pre-limenary Set-up stuff

cont = GameLogic.getCurrentController()

player = cont.owner

actlist = cont.actuators

move = actlist["move"]

#rot = actlist["rot"]


# Exciting Speed Atribute Set-up!

speed = player['modSpeed'] + 5

# Intriguing Rotation Attribute Set-up!

turn = player['modTurn'] / 100. + 0.03

### Control Set-up

# Fun Controller Command Setup!

senlist = cont.sensors

up = senlist["up"]

down = senlist["down"]

left = senlist["left"]

right = senlist["right"]

####### Function Time!

# Function for CHOO CHOOING!
def go ():

    player.setLinearVelocity([0.0, speed, 0.0],True)
    player['ForceLimitY'] = [0.0, speed, False]
# Function for cutting power
def off ():

# Function for Doughnuts!
# def turn ():



# activates move and rotation actuators


if up.positive == True:
elif up.positive == False:


alpha 0.002.blend (142 KB)

Better use CODE rather the QUOTE tags. You’re script is really difficult to read.

Ah, should have thought of trying just adding the code tag, I was looking for a “wizard button” at the top of the text box to do that but couldn’t find one.

The first one that jumps in my eyes is:

What is deactivate()?

The script interpreter aggrees with me and gives you an exception at the console.

Thanks for noticing that I never got around to writing the real function in, cont.deactivate(move) however I do find it odd that I wasn’t getting any error information about that when I was trying to run the BGE. Anyway, that seems to have had no effect on my problem with the servo controller not acting the way it should. If I hold down “w” for too long the cube starts to slow for some reason. Also, the cube is accelerating far faster than it should. Do you have any idea why?

Thanks for the reply,


I suggest to add some print statements to see what your script does.

Just to make an correction, there is no servo controller. You have an Python controller and two motion actuators in servo mode.

I do not really see why you need this two motion actuators, when you set the forces with you script. I would wether apply all forces with the script or only configure and toggle the actuators.

Why you describe sounds like you apply the force once. That could be because the script runs just once. You could see that when you add some print statements as suggested earlier. To fix that you can set the sensors to True pulse mode. See A Word on Pulsesfor more information.

The acceleration is set by your setLinearVelocity(). Maybe you should play with the speed parameter.

I hope it helps