Flipper action in python?

Hi all,

I dont know how to apply a flipper action to this, can someone please help me?

key = cont.sensors["key"]

key_i = bge.events.IKEY
key_w = bge.events.WKEY

if key.getKeyStatus(key_i) or key.getKeyStatus(key_w):
    scene.objects["pikachu"]   :::should play the flipper action called 'yeey' ::::

All a flipper action actuator does is play the action normally when it receives a True pulse and plays the action in reverse when it receives a False pulse. Additionally if the action is already playing, it will use the currently playing frame as the start frame.

You can easily implement this behavior in Python with the getActionFrame() and playAction() methods:

obj = scene.objects['pikachu']
currentFrame = obj.getActionFrame()

# replace END_FRAME and START_FRAME with the respective end and start frame of your action
if key.getKeyStatus(key_i) or key.getKeyStatus(key_w):
    obj.playAction('yeey', currentFrame, END_FRAME)
    obj.playAction('yeey', currentFrame, START_FRAME)

thanks Mobious, it gives me a lot of hints.

if key.getKeyStatus(key_i) or key.getKeyStatus(key_w):
    i_current = ic.getActionFrame()  
    ic.playAction('yeey', i_current, end)
    i_current = ic.getActionFrame() 
    i.playAction('yeey', i_current, start)    

this code seems working , the console doesnt give any weird error also. But the action just plays for the part of if statement, not for the else one. Which mistake do i have here?

hm i checked again, it gives an error at ‘else’. How could i then make a negative statement to the first line?

What is the actual error message?

hi Mobious

I recently fixed it by adding an always sensor ( with pulse) to the script. it works well now. Therefore i just used 1 Keyboard sensor (allkeys) for the script. so everytime i want ti flipper action to return to its start frame again, i must press something else than I and W.

Now i know how it works. Thanks Mobious

Why do you not just run the ActionActuator?

This way you do not need to constantly run the Python controller and it is much more generic then the above code.

hi Monster,

since i have 6 different objects and i want those to react with the same flipper action. so i add the code to an empty and it should then controll these 6 objects. ( for setvisible, action, sounds… also)