6
$\begingroup$

I want to know how to play(send true pulse) to an action actuator via script (logic brick with all the settings) since playAction doesn't have animation property which I need.

$\endgroup$
7
$\begingroup$

You can use python to activate the Action actuator with this script. You will need three logic bricks: A sensor (to trigger it all), the python controller, and the action actuator.
logic bricks

cont = bge.logic.getCurrentController()

act = cont.actuators["Action"] # the name of the Action actuator

if cont.sensors["Keyboard"].positive: # trigger when buton pressed

    #Set all the properties you want
    act.action = "CubeAction"
    act.frameStart = 1
    act.frameEnd = 30
    act.priority = 0

    cont.activate(act) # start the actuator

You can set as many or as few of the settings that you need with python or in the logic brick, however the python will overrule any duplicate settings. Here is a list of all the settings for the Action actuator.
Do note the the two minimum setting you need are the action name, and frame end.

$\endgroup$
  • $\begingroup$ c.activate(act) was the only thing what i needed but thx for all $\endgroup$ – terrio Mar 8 '15 at 7:49
  • 1
    $\begingroup$ Your code refers to the sensor and actuator explicitly by name. Could they be looked up by the "in" and "out" connectors of the controller brick? $\endgroup$ – Passiday Aug 28 '16 at 21:48
  • 1
    $\begingroup$ @Passiday no, you have to specify the logic bricks by name, or id. $\endgroup$ – David Aug 28 '16 at 23:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.