Turning on animations wi th properties.

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?

do not use a while loop. It stops the GameLoop.

Check your console for errors.

We need some more details:

  • what actuator is “run” and what does it do
  • where is “wkey” coming from

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’t explain why it does not work.

I would do that with logic bricks.

  • for testing
  • because there is nothing that requires Python

I can’t explain why it does not work.

I would do that with logic bricks.

  • for testing
  • because there is nothing that requires Python

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”

i anyway not understand if this is a bug or not.

the case here two:

or is right now (and first was wrong)

or is wrong now (and first was right)

in any case i not see other issue a part this (bit strange) behaviour

hint:
deactivate the actuators can be a bit mess, usually is better just change action

from “walk” to -> “wait” to-> “run” to -> etc

great post Monster! (regard python/brick) :wink: