Problem in shooting bullets

I am having problem with my shooting mechanisms. The problem is that if I press the fire key (which I have assigned in events) it shoots, but like a machine gun which I don’t want. I want to shoot bullet after 5 seconds the previous bullet was fired.

Plz help…

The screen shot of my event is also included.

Timers are what you’re looking for: http://wiki.compilgames.net/doku.php/gdevelop5/all-features/timers
:slight_smile:

There’re a lot of examples using timers, here in the forum and bundled with GD. The turret tutorial explains specifically your problem and how to solve it, around here: http://wiki.compilgames.net/doku.php/gdevelop5/tutorials/tank-shooter#shoot_bullets_with_the_turret

I have tried it but it doesn’t work. Even it does not shoot at all…

Plz help

How are you doing it now?, share another events screenshot, it’s hard to tell if we don’t know what you’re doing :wink:

I just did a similar feature! Here’s the relevant parts:

Not shown: You have to first create the timer, using the “Start (or reset) a timer” action.

Once the timer is running, GDevelop knows its value. If you check the timer’s value and it is greater than 1 ( > 1), the timer has been running for more than one second. It’s better to check if the timer is greater than or smaller than your target value, rather than if it equals the target value - your timer might hit 0.992 and 1.002, but not 1.000!

I use variables to control the rate of fire. By calculating the cooldown as 1 divided by rate of fire, I can give rate of fire a value of 3, and the ship shoots 3 times a second. I also store whether the bullet is ready to fire in a variable. I give it the text value of “true” or “false”, and check for those.

Looks fine, try to debug the timer value: Add a text object and put it in the scene, then always update the text string to be:

ToString(Ship_Basic.ObjectTimerElapsedTime("rate_of_fire"))

This will show the timer elapsed time in seconds, check if it increases along the time and if it resets on key press.