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$

1 Answer 1

8
$\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$
3
  • $\begingroup$ c.activate(act) was the only thing what i needed but thx for all $\endgroup$ Mar 8, 2015 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, 2016 at 21:48
  • 1
    $\begingroup$ @Passiday no, you have to specify the logic bricks by name, or id. $\endgroup$
    – David
    Aug 28, 2016 at 23:20

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .