Python error

Im getting the error that “W = cont.sensors…” is calling for an object that is not callable, any help? im trying to learn python, by making examples. it is quite hard to get some good explanation on how the game engine works, thank god i understand how it works. sorta.

def move():
	cont = GameLogic.getCurrentController() # this can be avoided, see run_2
	W = cont.sensors('w_bla')
	A = cont.sensors('a_bla')
	speed = 120
	force = [0.0, 0.0, 0.0, 0]

	if w.positive:
		force[1] += SPEED
	if s.positive:
		force[1] += (SPEED * -1)
	if a.positive:
		force[0] += (SPEED * -1)
	if d.positive:
		force[0] += SPEED
	print force

any help would be appreciated, and yes this code is from nanoshooter.

cont.sensors(‘w_bla’) -->

cont.sensors is a sequence with dictionary like access not a function.

Thank you very much! Also, if I would like to edit an actuator’s properties (like Force and everything, what would be the best way?)

Thank you soo much, its an array, not a function… or ‘list’ w/e

just try

provided you have an actuator named actuator

actuator = cont.actuators['actuator']
print dir(actuator)

this will tell you what you can do to manipulate the actuators properties.
just play around with the dir(), its incredibly useful for debugging
…and have fun


Thank you all for replying, i have another question now:

I have a cube, which i move around with servo, well big whoop nothing fancy there, but i have a camera which has the cube as a parent, when the cube moves/rotates I do not want the camera to rotate with it… how do i do that?

something called vertex parent i think

to vertex parent an object to another just get into the parents edit mode, select one OR three vertices then shift+click the child and press strg+p once both the vertex and the child object are outlined.

that should do it


thanks a bunch!

Now for maybe a more advanced question, As i am trying to learn i want the cube in the center of the screen to be facing exactly where my mouse is, i have made it so that i have 2 variables : x, y that give off the position of the mouse in proportion to where my cube is

any way to make the cube rotate towards the mouse?