I my BGE python script, I have


But when I run the code only last one runs.The difference is in the timeline. One is from 0-20 and other is from 30 to 42.


You can run actions simultaneously by setting them on different layers.

However, playing the same action will result in weird overlapping issues. For example, when the loop starts at frame 30, it will inherit the positions etc set in the previous frames. The first action will appear to do nothing.

You'll want to use separate actions and different layers.

obj.playAction('name_of_first_action', 0, 20, layer=0, play_mode=bge.logic.KX_ACTION_MODE_PLAY)
obj.playAction('name_of_other_action', 30, 42, layer=1, play_mode=bge.logic.KX_ACTION_MODE_LOOP)

And if you need to stop it later:


The playAction method simply executes the issued play directive, so the last issued is the one that plays.

  • $\begingroup$ this was flagged as low quality, can you add some more to your answer. $\endgroup$
    – David
    Nov 8 '14 at 15:32
  • $\begingroup$ @David For what reason? I mean, the implied question here seems to be: "Why does only the last one run?", and I think my answer explains that fully. $\endgroup$ Nov 8 '14 at 16:02
  • $\begingroup$ the SE system automatically flags posts that are short, among other reasons. There is nothing wrong with what you wrote, but you may be able to add more to explain why or add a solution. $\endgroup$
    – David
    Nov 8 '14 at 16:23
  • $\begingroup$ @GoranMilovanovic How to run both? $\endgroup$
    – user5507
    Nov 10 '14 at 4:40
  • $\begingroup$ @user5507 You can only play one action at a time. $\endgroup$ Nov 10 '14 at 12:49

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.