Fire rate of bullet help

Get help using Construct 2

Post » Sun Jun 24, 2012 1:07 pm

My character shoots when I tap CTRL, problem is he shoots every time CTRL is pressed, how do I give the bullet a fire rate? so the player can tap CTRL how much he wants but will only shoot one bullet every 1 seconds.
B
9
G
1
Posts: 41
Reputation: 1,259

Post » Sun Jun 24, 2012 1:19 pm

see there is 2 way to do that :
1) event:condition1:keyboard : ctrl pressed
        condition2:every x second
        action:player:spawn bullet
but this is kinda buggy so i will say try to use the second one its 100% working perfect ^^
2)event:condition1: keyboard: ctrl pressed
        condition2: system: compare two values -> bullet.count <= 0
        action:player:spawn bullet
in this one you will do bullet when there is no bullet in the screen so you should destroy the first bullet if you want to shoot again :P so add this to actions
        action:system:wait -> 2seconds
        action:bullet:destroy
B
45
S
15
G
6
Posts: 795
Reputation: 11,935

Post » Sun Jun 24, 2012 1:53 pm

@zsangerous
I prefer the 1st one, thanks for the help it works now :D
B
9
G
1
Posts: 41
Reputation: 1,259

Post » Sun Jun 24, 2012 1:59 pm

your welcome :P an advice try to understand the events ^^

simple way to understand them :
if (condition1+ condition2+...+ subevents if it has) will do (actions)
B
45
S
15
G
6
Posts: 795
Reputation: 11,935

Post » Sun Jun 24, 2012 2:16 pm

I had the same problem, I went away and created a created a Global variable, "true"/"false". What I did from there, was when the player hit the fire button (In my case it was the mouse) it would also look to see what value the Global var was, if it was true, it would shoot, if it was false, it wouldn't. Then after I shoot the bullet, I set the Global var to false, and then did a System>Wait 1 Second and set the var to true. This is also how you would go about doing an automatic. Cheers mate.
B
10
S
3
G
3
Posts: 45
Reputation: 2,984

Post » Sun Jun 24, 2012 2:28 pm

Just out of curiosity, how would you do an automatic shooting? for example I hold CTRL and it will shoot auto until I let go of the button?
B
9
G
1
Posts: 41
Reputation: 1,259

Post » Sun Jun 24, 2012 2:33 pm

@TehChikenHater good idea but why you used it :P hehehe i think there is more ways to do this also but just use the simplest :) so in the future you can edit them when you want ,lets say the player want to shoot 2 shoots then he must wait? what will you do XD?

by the way, i like when i see someone try to do something even if its wrong :)


keep going and good luck :)
B
45
S
15
G
6
Posts: 795
Reputation: 11,935

Post » Sun Jun 24, 2012 2:35 pm

My way works. It's in my current game Alien Rampage! find me on Kongregate, then play the game. Once you get 500 cash, press 1; which will buy the automatic, then fire and it won't spam the screen.
B
10
S
3
G
3
Posts: 45
Reputation: 2,984

Post » Sun Jun 24, 2012 2:36 pm

@cmr32 (Name wrong?)

You would you the Mouse>Button Is Down event.
B
10
S
3
G
3
Posts: 45
Reputation: 2,984


Return to How do I....?

Who is online

Users browsing this forum: mercuryus and 16 guests