Shooting Delay

Get help using Construct 2

Post » Sat Jul 07, 2012 6:11 am

Hi.. i am having problems with creating wait time..before another cannon ball can be shot.. I have set my firing cannon balls on spacebar pressed..and i have set a wait time..and have also set an instance variable..on the player cannon balls....

so here whats my events look like
+keyboard On space pressed - wait 1 sec
+player cannon ball = 0    - Spawn a player cannonball
                           - Set cannon to 1




+playercannon cannon= 1    - wait 2 seconds
                           - Set cannon to 0

so basically what i want to do is fire the next cannon ball after 2 seconds from the previous cannonball was fired was fired...above events helps to create a delay..but if i keep tapping space continously..it fires the cannonballs without any delays..

here's a capx.
https://dl.dropbox.com/u/67865856/prototype_Avichal_2.1.capx
B
7
Posts: 28
Reputation: 781

Post » Sat Jul 07, 2012 9:14 am

I don't know if there's a more elegant way, but here's how I do it:

Player instance variable : RPM_Count (0)
Player instance variable : RPM (eg 480)

> System > Every tick >
> Mouse > Left button is down > add RPM * dt to RPM_Count

      > RPM_Count >= 60 > Fire bullet event and Set RPM_Count to 0

Mouse > Left button released > Set RPM_Count to RPM (so that the gun is ready to fire immediately - may want to not include this for a cannon)

Using an RPM of 480 results in a perfect 480 rounds per minute or 8 rounds a second regardless of FPS. If that's not clear let me know.Khalan2012-07-07 09:15:49
B
9
S
2
G
3
Posts: 75
Reputation: 1,964

Post » Mon Jul 09, 2012 1:04 pm

[QUOTE=Khalan] I don't know if there's a more elegant way, but here's how I do it:

Player instance variable : RPM_Count (0)
Player instance variable : RPM (eg 480)

> System > Every tick >
> Mouse > Left button is down > add RPM * dt to RPM_Count

      > RPM_Count >= 60 > Fire bullet event and Set RPM_Count to 0

Mouse > Left button released > Set RPM_Count to RPM (so that the gun is ready to fire immediately - may want to not include this for a cannon)

Using an RPM of 480 results in a perfect 480 rounds per minute or 8 rounds a second regardless of FPS. If that's not clear let me know.[/QUOTE]


i tired doing exactly what you said.. it didn't work..may be i am doing something wrong..
B
7
Posts: 28
Reputation: 781

Post » Mon Jul 09, 2012 1:13 pm

Here's a quick and easy way to do fire cooldowns:

CooldownMAX.capx (r98)
B
27
S
8
G
8
Posts: 903
Reputation: 8,452

Post » Mon Jul 09, 2012 7:45 pm

thanks this looks great.. i some how managed to get it fixed on my own.
here's how i did it :)

https://dl.dropbox.com/u/67865856/CooldownMAX.capx
B
7
Posts: 28
Reputation: 781

Post » Thu Apr 30, 2015 1:47 am

Thanks that helped me a lot! :mrgreen:
B
4
Posts: 3
Reputation: 218

Post » Thu Apr 30, 2015 2:57 am

Actually if you can help, (I know its been 3 years) I'm trying to add this to all my guns in the game. I've been using Nimtrix's idea but will only work for one gun. Barc0d3guy's way doesn't work because I need it to be a global variable so I can increase the total speed for it to take to shoot. Is there a way to do this for multiple guns?
B
4
Posts: 3
Reputation: 218


Return to How do I....?

Who is online

Users browsing this forum: h1k3, LeFuji and 18 guests