How to use the timers

I dont understand how does the timer works. for example : i want a enemy to shoot every 5 seconds. but i dont know how to do that :confused: [size=150]can u help me[/size]? :stuck_out_tongue:

I’m not sure how to use them either.

You can “cheat”, however, if you make a Sprite with 2 frames and make each frame play for 2.5 seconds, then activate it when the animation finishes.

I was confused too at the start, since timers have no list or editor where they are collected, they just exist under a name if you use the “reset timer” action. That’s basically how you start a timer.

For fire rate you’ll want to reset the timer whenever your event fired a weapon. You’ll also need the same timer as a condition that prevents the fire event from being execute, unless the timer has reached a certain value. In your case five seconds.

As the example shows you can also have dynamically adjusting fire rates by using variables for the required timer values.

That’s really all there is too it: the “reset timer” action essentially starts the timer, “timer value” condition checks the timer and governs if something you want to be timed can be executed.

The animation thing is a cool workaround though, I used that to destroy projectiles without the need for timers. Pretty neat. :slight_smile:

sleeper_service covered it pretty well here. :smiley:

I actually learned about timers from Matthew Cornelius’ space shooter tutorial on YouTube a few months back. You should check out his entire Shooter series if you’re new to GDevelop. :slight_smile:

I used “unpause timer” to start a timer. Im not sure if it is correct but it worked for me. :smiley:

Condition:
Action: unpause timer "enemyfire"

Condition: if enemyfire timer > 5 seconds
Action: create bullet
Action: reset timer "enemyfire"
Action: pause timer "enemyfire"