Different fire rates for different instances

Get help using Construct 2

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

Post » Fri Mar 22, 2013 7:57 pm

@excal...you have set the variable fire to the same as the firerate to begin?....
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:59 pm

also you should not need "for each"...
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 8:02 pm



I have it so that after the enemy is created, it has its firerate and fire set, so yes.
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:32 pm

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
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 10:26 pm

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?Excal2013-03-22 22:28:17
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 11:32 pm

Basically you want a random range for your fire rate,so I suggested set a range for each enemy type...and if you want variation in that...subtract a random amount from the initial value upon creation...

There should be nothing wrong with the way you are randomising the value....but it does not appear to be working for you...not sure why.

I believe values on creation can be missed due to the way C2 runs it's events sometimes...maybe try a wait 0.1 after creation see if that helps.

as I saiid it appears to work here.
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 » Sat Mar 23, 2013 6:28 am

Here is an old example you should be able to apply in your situation:

Gun example

If you take the first few events and simplify them for one weapon, you'll have what you want. It's basically the same idea as before, you'll add dt to a variable until it is greater than the fire rate, when it is the gun fires. Then you set the variable to 0 and start all over again.

Like I said before, you are missing the 'for each enemy' from the point where enemies fire; if you don't have 'for each' every ship will take fire rate variable from the first instance of enemy ships. :)
B
24
S
8
G
7
Posts: 756
Reputation: 7,192

Post » Sat Mar 23, 2013 6:36 am

Thanks (again) vee!

I actually was able to piece together a solution just before your post, haha. I am just now getting used to using dt (it's not really a 'natural' thing for me to think of using yet), so bear with me as I slowly learn more of this advanced stuff.
Project Lead of Zems Online Card Game

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

Previous

Return to How do I....?

Who is online

Users browsing this forum: randomly and 17 guests