Taken damage from multiple enemys

0 favourites
  • 7 posts
From the Asset Store
Give Sound to the enemies that are part of your game! :)
  • Hello Guys !

    Since a long time i try to receive from my hero damage from multiple enemy's source.

    I would like to do this :

    When an enemy is coming in Hero's line of sight, enemy do animation "attack" then deal his "damage" every ""his attack speed" seconde"(And subtract damage to health bar).

    But ! when a second enemy is coming, this second enemy deal his damage with his attack speed. (And subtract damage to health bar)

    I try lot of things with for each, array, while but always just 1 enemy deal his damage.

    I hope u understand my problem.

    Thx for help !

  • Can you attach a capx file of what you did so far? It would help as I think there is possibly more than one reason why this is not working and all of them need to be fixed. And I can only guess what those issues might be.

  • I just update with a screenshot

  • I think this is because despite the "foreach" loop the events are simultaneous.

    A solution :

  • Thx for ur answer Coincoin.

    I try ur solution but just 1 enemy is dealing damage. (-1hp/s)

    I would like that all enemy in range deal their own damage with their own attack speed.

    U can download my example here :

    dropbox.com/s/9ejknwormov6m

    2v/Example_Multiple_Enemy_Damage.capx?dl=0

    My hero have to take -20hp (10x2) each second, but here he just take 10 each second.

    ^^ thx for help

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Here's how I did it with timer behaviour added for enemies, turns out it is a bit more complicated than expected (not too much though). Add (repeating) timers equal to attack speed for all enemies. Basically on timer end do actions for each enemy (this is important otherwise just one enemy does the damage). Keep track of who has a timer initiated with a boolean. Stop them once enemy is out of range.

    I recommend clicking between the two squares to the left to move the player there. Every 15 seconds they attack simultaneously and player HP should drop by 5+3=8.

    https://www.dropbox.com/s/etpdvfta51ck9 ... .capx?dl=1

  • Thx pulsar ! It's work great.

    And without line of sight, nice !

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