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.
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)
else:
obj.playAction('yeey', currentFrame, START_FRAME)
if key.getKeyStatus(key_i) or key.getKeyStatus(key_w):
i_current = ic.getActionFrame()
ic.playAction('yeey', i_current, end)
else:
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?
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.
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)