Different fire rates for different instances

Get help using Construct 2

Post » Fri Mar 22, 2013 7:09 am

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.



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

Producer at Impulse Limited
B
18
S
6
G
3
Posts: 677
Reputation: 5,194

Post » Fri Mar 22, 2013 8:15 am

Just a possible solution
http://db.tt/j1dJYKKz
B
20
S
8
G
6
Posts: 176
Reputation: 8,047

Post » Fri Mar 22, 2013 8:37 am

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.
Project Lead of Zems Online Card Game

Producer at Impulse Limited
B
18
S
6
G
3
Posts: 677
Reputation: 5,194

Post » Fri Mar 22, 2013 9:44 am

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

http://db.tt/xoSx3uw4
B
20
S
8
G
6
Posts: 176
Reputation: 8,047

Post » Fri Mar 22, 2013 10:04 am

Also with adding another instance variable for speed, the effect will be more visible
http://db.tt/sdHj5aGH
B
20
S
8
G
6
Posts: 176
Reputation: 8,047

Post » Fri Mar 22, 2013 6:24 pm

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.Excal2013-03-22 18:25:31
Project Lead of Zems Online Card Game

Producer at Impulse Limited
B
18
S
6
G
3
Posts: 677
Reputation: 5,194

Post » Fri Mar 22, 2013 7:09 pm

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

SpaceGame.capx
Project Lead of Zems Online Card Game

Producer at Impulse Limited
B
18
S
6
G
3
Posts: 677
Reputation: 5,194

Post » Fri Mar 22, 2013 7:32 pm

@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 perfick2013-03-22 19:33:25
As long as I can move left, right and fire, I'm Happy...
B
42
S
15
G
11
Posts: 655
Reputation: 12,260

Post » Fri Mar 22, 2013 7:47 pm

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.
Project Lead of Zems Online Card Game

Producer at Impulse Limited
B
18
S
6
G
3
Posts: 677
Reputation: 5,194

Post » Fri Mar 22, 2013 7:53 pm



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.Excal2013-03-22 19:54:06
Project Lead of Zems Online Card Game

Producer at Impulse Limited
B
18
S
6
G
3
Posts: 677
Reputation: 5,194

Next

Return to How do I....?

Who is online

Users browsing this forum: imnotspecial, totoe and 12 guests