Im playing around with animation actions and properties. I feel like the script below should work but doesnt.
if not "run" in owner:
owner["run"] =False
run = controller.actuators["run"]
if wkey ==2:
owner["run"] = True
owner.applyMovement(0,5,0)
if owner["run"] == True:
controller.activate(run)
The owner moves as it should. But the animation doesnt play. Any thing im doing wrong or will it not work like this? Maybe I should use while?
Wkey is a keyboard event. It is defined properly. I just left it out of the post. Run is an action on an armature parenteed to the object with this script. run works properly when its directly under 'if wkey… I was just wanting it to turn on when the property changes to true rather than the
keypress itself. Keypress Does change property to true as it should.
I can do it with logic bricks. I actually had all my movements in python on my (cube) and logic brick animation on the armature itself.
Ive always assumed that you should use python when you can rather than logic bricks. Is that not the case? <-important to me :D…sometimes i spend hours learning something in python I can do in just a few minutes with logic bricks. I just thought it was always good to use python and eliminate logic bricks when you can.
you must call(activate) only one time the actuators action (from blender 2.6)
this line is ever true so you re-activate all time the actuator and so not work
if owner["run"] == True:
controller.activate(run)
this is the code “correct”
if not "init" in owner:
owner["init"]=1
owner["run"] =False
run = controller.actuators["run"]
controller.activate(run)
if wkey ==2:
owner["run"] =True
owner.applyMovement(0,5,0)
(of course owner[“run”] is not relevant in this case )
if you want stop the action you must using “deactivate”