every seconds

0 favourites
  • 4 posts
From the Asset Store
This is a Dungeon Master tool & the 1st of 12 Combat Engines from the Building Combat Engines for Browser Games workshop
  • hi all ,

    i have an enemy that spawn a bullet every 2 seconds and i have 3 enemys in screen i want first one spawn bullet then after 1 second the 2nd one spawn and 3rd after 2 seconds, so the bullets will spawn every 2seconds on all of them but there is a diffrant start time,

    is there a way to do that??

  • Have three characters that each spawn a bullet every two seconds. This should be done by a simple 'for-each' loop, while waiting two seconds. But the problem with that is, essentially, that they'll be all shooting at the same time.

    So, what you need to do, is to check for when you want them to start firing. This can be done different ways, by checking the nearest enemy, and then seeing if the distance between them and the hero is less than X amount of pixels, or just to activate it when they're all on the screen. Either way, you could set up a global variable that is called 'EnemiesStartFiring'.

    Before you go any further, give each enemy its own boolean variable, called 'ActivateFiring'. Make this condition as part of the 'for-each' loop mentioned above (so in the single action, it should be: for-each ENEMY | Wait 2.0 Seconds | Enemy.ActivateFiring = true.

    Anyway, when EnemiesStartFiring = 1, make an action that sets the ActivateFiring of the closest enemy to be true. Then have the System wait 1 second, and set the second enemy's ActivateFiring to be true. Then, have it wait an additional second before setting the third enemy's ActivateFiring true. Make sure you set EnemiesStartFiring to 0, otherwise that will continue to loop.

    Does that make sense?

    In one of my combat games, I simply have each enemy attack whenever they're within a certain range of the hero. It works well enough, but there's no coordination between the enemies.

  • brockatkinson

    i think if i did all of what you said it will work but the problem in the first step i sticked , the problem is when i made these

    <img src="http://i49.tinypic.com/8zfhgm.jpg" border="0" />

    i couldn't try my game everytime i try to preview it ,it crash and say reload... (im using chrome).

    is there a problem of what i have done? just tell me how to create the loop thingy , thanks for the help^^

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I think it's your While loop which is the trouble.

    Instead of the While, replace that with System.Every X Seconds (2 seconds). Then give it a go.

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