Python - 2 Sensors

Hey,
Sorry if I am a pain in the az to you all about my questions but I really can’t find the answer. :no:

I made the following script:

cont = GameLogic.getCurrentController()
own = cont.getOwner()

W = cont.getSensor(“W”)
Q = cont.getSensor(“Q”)

run = cont.getActuator(“Run”)
walk = cont.getActuator(“Walk”)

if W.isPositive and Q.isPositive():
GameLogic.addActiveActuator(run, True)
else:
GameLogic.addActiveActuator(run, False)

When I press W, it doesn’t do anything.
When I press W and Q, it works.
But when I press only Q it still works… Which it shouldn’t…

Thanks already.

there are the () missing behind the W.isPositive.

line should read:

if W.isPositive() and Q.isPositive():

btw it would be wise to switch to blender 2.49 :slight_smile:

i find the python to be a lot more intuitive since the upgrade.

the code you used would be:

cont = GameLogic.getCurrentController()
own = cont.owner

W = cont.sensors["W"]
Q = cont.sensors["Q"]

run = cont.actuators["Run"]
walk = cont.actuators["Walk"]

if W.positive and Q.positive:
	cont.activate(run)
else:
	cont.deactivate(run)

which, imho is much nicer than the old syntax :slight_smile:

Lol, thanks.
And I have newest blend but didn’t knew about the script. :stuck_out_tongue: