Different fire rates for different instances

0 favourites
From the Asset Store
Adjusting the game screen for different resolutions (Letterbox scale)
  • I have an instance variable that stores the fire rate for each instance. This instance variable is assigned a value every time the object is created, but I'm still having the issue where the objects fire at the same rate.

    <img src="http://i.imgur.com/YgfiIIb.png" border="0" />

    Can't think of another way that 'should' be correct, and what I have isn't creating different fire rates. Anyone have any ideas?

  • Just a possible solution


  • They're still firing at the same rate. What you have essentially done is change which ones fire.

    I need all my enemies to be firing, but at different rates.

  • Actually their frame rates are 1,2 and 3 second. You can check the instance variable.

    Because of it at every 2 seconds, upper 2 sprites firing at the same moment (because 2 dived to 2 and 1), at every 3 seconds, top and bottom sprites firing at the same moment(3 divided to 3 and 1), and every 6 second all of them firing at the same moment (because 6 divided to 1,2 and 3)

    If you choose different rates you can see it easily. For demonstrating i uploaded a second one


  • Also with adding another instance variable for speed, the effect will be more visible


  • Interesting examples, but I'm not sure how to apply it to my program.

    I don't have a global variable that allows you to "artificially" set variable firing rates, I have enemies on screen that equal the current wave (level) and each enemy should be firing at a different rate. I am not given the luxury of using a global variable to divide by, as I need the firing rates to be random.

    If you take a look at my screenshot above, you can get a general idea of what I am trying to do. I need the enemies to be firing equal to their fire rates.

  • Here's my project file in case you want to look.


  • Excal I suggest using delta time to get the firing rates doing your bidding....

    you already have a firerate variable set?..create another named fire...have a condition as so

    enemy "fire" greater than 0...subtract 0.1*dt from fire

    and condition

    enemy "fire" less or equal to 0...fire shot

                                           set "fire" to enemy "firerate"

    that should work...

    Also not sure I'd advise posting your entire capx..when you put so much effort in...just my thoughts...

  • Pixel, that makes perfect sense, thank you!

    As for my sharing my .capx file, all art assets I'm using is placeholder anyway so I'm fine sharing it for now.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • <img src="http://i.imgur.com/8wYgTDZ.png" border="0" />

    Now the enemies aren't firing at all :/

    Do I need to be picking each instance? I tried a For-Each and ran into the same problem.

  • have set the variable fire to the same as the firerate to begin?....

  • also you should not need "for each"...

  • <img src="http://i.imgur.com/KY4qh3H.png" border="0" />

    I have it so that after the enemy is created, it has its firerate and fire set, so yes.

  • It worked here when I edited your capx...but I set the variable up on the properties bar...maybe change random(1,3) to subtract int(random(3)) from firerate..upon creation

  • I'm not a fan of setting it up in the properties bar because some conniving coder could change it and 'cheat'.

    By setting it dynamically through an event, I prevent most attempts to 'cheat' the game.

    I'm not sure what subtracting random(3) does. Could you explain the logic behind that?

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