Python Actions

Hey guys how do you use Python to control actions? i know its a n00b question but i’m stuck. this is what i’m trying to convert into Python. the second photo is what i came up with and its the wrong way to do it haha.

Attachments



addActiveActuator() is deprecated. If you replace it with cont.activate(‘yourActNameHere’). That might help you if the actuator is not activating, also, did you remember to set the start and end frames of the action? If you didn’t set a end frame, and it says 0, it won’t play. I forgot to do this when I replaced that rather unwieldy stack of actions myself. :smiley:

before you replied i found a code like this

run = cont.actuators[‘run’]

run.action = “Walk1”
run.frameStart = 1.0
run.frameEnd = 40.0
run.useContinue = False
run.mode = 4
run.setBlendin(5)
cont.activate(run)

and its great but how do i set it up to only trigger when a specific Sensor i specify is activated?

like if uparrow.isPositive():
run.action = “Walk1”
run.frameStart = 1.0
run.frameEnd = 40.0
run.useContinue = False
run.mode = 4
run.setBlendin(5)
cont.activate(run)

you go it:


if uparrow.isPositive():
  run.acti... 
  ...

Yeah i’m doin that right now and it doesn’t work… i dont get it. http://img265.imageshack.us/img265/6259/screenshot20100727at123.png

hey i think i got it now. i’ll mess around with it until it works right. once i get it i’ll post so if anyone else has an issue they can see