The template for a Logic Brick

How does this picture

look in python.

I gave it a few shots like adding fire = cont.actuators(“CannonAction”) but still wasn’t able to get it to go.

If someone could please take the time to relate the picture to phython scripting, I could probably plug the variables as needed through my adventure. It would be a great template.

Thank you,

I already have the keypart, that wasn’t hard to figure out (thank you tutorials everywhere)
if bge.logic.KX_INPUT_JUST_ACTIVATED ==[]

You just need to call the ‘playAction’ method on your Armature object.

so to find the actual object name, so I can find the sytnax, playAction() in this case; can I use the 3rd option to the right in the Logic Editor? Meaning if I wanted to use code instead of the logic editor, but I needed to know the syntax per object in the logic editor, are they generally matched up?

It should be as simple as this. It just checks to see if the space bar is pressed and if so triggers
plays the ‘CannonAction’.

def actionTest(cont):
  own = cont.owner
  if bge.logic.KX_INPUT_JUST_ACTIVATED ==[]:
    own.playAction('CannonAction', 1, 30,)

Each Controller is associated with a specific GameObject at run time. So if you want to know which GameObject you should be working on, you ask the Controller who it is associated with.

the problem I am having is that I am calling tank as object. So when I run playAction(), it’s basing the geometry on tank and not a child of tank called Canon. So how do I essentially do;

since tank = cont.owner

So I instead create a class Tank and create each child even though that’s already done in the scene/object editor? Sorry look it up just points to rewritting what I have already associated in BGE. I just want to use playAction() on a child object of tank(the parent).

KX_GameObject has a list of child objects. So if your ‘tank’ knows that it has a ‘cannon’ object as a child you can do something like this:

Pseudo code:

cannon = own.children['cannon']

Thank you for the information and time in replying.