Enemy loop problem

0 favourites
  • 5 posts
From the Asset Store
SynthWave Loop Pack includes 68 seamless loops, founded on 11 original melodies. For use in game and custom works.
  • Hi

    I'm having a little trouble getting something to work and a bit confused as to why it won't work.

    The basic logic I want to occur is when you hit the enemy first time it plays it's hit animation. If it get's hit a second time it plays it's death animation and the objects are destroyed.

    What I originally tried was to include the 'on animation finished' command in the for each loop but this gave an error during testing (error at bottom). So I moved the 'on animation finished' commands outside of the for each loop but this now means it affects all the enemies and not just the unique UID enemy.

    Screenshot of the enemy code below. Any ideas what I am doing wrong, what should I use instead of the 'on animation finished' command (I need to wait for the animation to finish otherwise the other condition becomes true and it dies straight away)



    <img src="https://dl.dropbox.com/u/3796932/enemy_loop.jpg" border="0" />

    <img src="https://dl.dropbox.com/u/3796932/enemy_loop_error.jpg" border="0" />

  • Why not just add a Family instance variable called "Health" to the enemy FAMILY...

    Then when you hit the enemy instance set up an Action that subtracts half its Default Health on each hit..

    then use the Variable Health = 0 function call to change your animation to the right one...these commands are called every tick anyway so you don't really have to worry about the system missing it..

    The important thing to remember is to add a System "For Each" Enemy Family condition as well...this will make it work separately for every instance in the family

  • Thanks fro the reply Mystazsea.

    I had a go with the family but still had the same issue. The basic problem is triggering a new event when an animation finishes playing. At the moment I can't put the 'on animation finished' command in any loops.

    Are there other ways to do something after a certain animation has finished?



  • Not sure off the top of the head why your specific animation isnt working, but there's an alternative way to trigger something when an animation finishes.

    You can compare a value to which frame your animation is currently on.

    so you could do "if death animation = frame 10 then"

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Ah, thanks Justifun. I will give that a go... that does sound like it will work.

    Thanks again


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