How do I fire weapons in a burst mode?

0 favourites
  • 3 posts
From the Asset Store
Full game Construct 2 and Construct 3 to post on Google Play
  • So the thing is that I want my starship to shoot its lazers in an automatic mode. I've done that but when it comes to making it shoot those lazers in that burst mode I always end up failing to get the coding done.

    For instance, I want the starship to shoot 10 times and then wait for lets say 3 seconds until shooting again those 10 times and so on:

    10 blasts - 3 seconds - 10 blasts - 3 seconds...

    I've tried using loops but I don't seem to be using them the right way.

    Could anyone help me out with the commands?

    Just a reminder, the starship isn't firing in turret mode

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • OK. What about you give the starship an instance variable called shotsToFire with a value of 10, and another one called shotCoolDown, with an initial value of 0. Then in events we can do this, no need for loops:

    • shotsToFire > 0 & shotCoolDown = 0: Fire a laser, subtract -1 from shotsToFire. Set shotCoolDown to 10

    [you might have to experiment with the shotCoolDown number, I just made it up; but it's the number of frames the game will wait between each shot in the 10-burst so it isn't literally firing once every frame, which will look horrible. With 10 in this value, the game will fire a laser, wait 10 frames, and then fire another, etc.]

    • shotCoolDown > 0: subtract -1 from shotCoolDown.
    • shotsToFire = 0, trigger this event once: wait 3 seconds, set shotsToFire = 10.

    And that's it. I haven't tested it, but something very much like that will do the job for you.

  • This kind of this the job. I still have to deepen into the numbers and variables but thank you for your time man!

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