Restart animation issues

0 favourites
  • 4 posts
From the Asset Store
Ninja char for your game! Make your own Shinobi game with this art.
  • Hello great community! This is my first post ever in this forum and I'm happy using Construct 3 and I hope not to make some mistakes in my topic.

    So, my problem is this: in a really simple beat-em-up, when an enemy hit my hero (called "mainCharacter"), it spawn a hit box (hitBoxEnemy) which is destroyed after 0.2 seconds (it appears just for a little time).

    When the hitBoxEnemy triggers "On_collision" event with my hero, my hero gets into a "HIT" STATUS and then starts his "hit" animation.

    My problem is: IF my enemy hits my hero a second time BEFORE my hero is finishing his "hit" animation, my hero doesn't start over his "hit" animation. Why? I tried so many ways you cannot even imagine, and I suppose I'm using in the right way "Set animation" and "Start animation" actions, but the second action never triggers.

    My final (non-sense) approach which works just fine is to add a useless action which triggers "Start animation" action... it sounds strange but it works.

    Below you see what I'm talking about: if I remove "Set animation speed to 7" action, next action "Start animation from beginning" NEVER triggers, NEVER!

    Can somebody help me and advise me, if there's a logical problem I can't see, or is the engine?

    Thank you so much.

  • Why do you need two events "hitBoxEnemy on collision with mainCharacter"? Because the second one is a sub-event, it may trigger at a different time and cause some unexpected issues.

    Try combining both events into a singe one. I'm not sure if this will fix the problem with the animation, but at least you'll have an optimized easy-to-read code.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Thank you for your advice. Actually I've already tried your method, but for safety, I tried it again, but still, it doesn't work. I do not understand if it's my problem or Construct's, and I'm kind of stubborn and I do not like that gimmick I created.

    Talking about syntax, I agree with you, but actually all "mainCharacter" events are split in his different STATUSes, so theoretically the transition to "HIT" STATUS would be inside each other STATUS' events. But, instead of copying the same event 4-5 times, I preferred to put the collision event only once outside.

    Thank you anyway. I hope to solve this puzzle in one way or another.

  • Finally I got it! I discovered that's there a kind of a bug in Construct. The problem was "Start animation" action combined with a Ping-pong animation while is was in its reverse-part/going backwards. I mean, my "hit" animations start over each time the collision happens when frames are moving from 0 to the last one, which is 3. If the collision happens when the animation is going backwards, from 3 to 0, it doesn't execute "start animation" action, unless you add another animation action before which "resets" animation handling.

    Thank you for your help, I hope this information will be helpful for somebody else.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)