[Solved] How do I add time to a timer

Hello lovely people,

I’m still quite new to programming so please bear with me.

I currently have a countdown timer on my game which counts down from 90 seconds. The countdown timer can be seen by the player. What I would like to do is set things up so that when an enemy is defeated, 20 seconds is added to that countdown time.

Any idea on how to do this?


Like this:

Are you using the CountDown Timer extension?

1 Like

There’s a countdown extension?!

No. I wasn’t even aware there was a countdown extension. I basically been doing my countdown like this.

What is the name of the extension?

Thanks for the reply. I have to confess I don’t really understand this. is this something to do with the extension? was this something that’s attached to the enemy? or variable of some kind? how does this link with the rest of the coding/game build?

my apologies for my lack of knowledge. I’ve only been teaching myself how to do this for the past couple of months!

Hi, first you have to install extension Countdown Timer:

Then you start your own countdown timer, set the value to 90.

In previous post I was showing action how to add 20 seconds in event, when your conditions are fullfiled.

In this action value of timer is set to new value with adding 20 seconds to actual value:

You can use the extension. Retracted - the extension doesn’t appear to work

To keep using the method you are in the screen snip. change that 90 (which is being subtracted) into a variable, and increase the variable value by 20 (or whatever value).

BTW, to avoid using abs (because when the timer is greater than 90 then the countdown becomes a count up) use “90 - TimerElapsedTime("highscoretimer)

That countdown timer extension doesn’t work. I created a test app using the events you posted and it doesn’t countdown. I’ve checked the functions and cannot see where it starts the timer or even regularly updates the timer.

Okay, you might have to be very patient with me. I’ve only just started getting my head around variables and did my first one a few days ago ( having the health bar increase when an enemy is killed.) How would I set up a variable for the timer? How do I include that variable in this bit of code?

It’s a shame the countdown extension isn’t working, does that could have been a great way of doing this!

It must be old. Back when the timer would be created just by checking it’s value.
There’s at least 1 depreciated condition

It is old, and it is relying on the timer getting created automatically. What gets me is that there’s no update function that reduces the timer value - it’s only done when calling the start or reset timer action.

Have a looks at this post from a few weeks ago. It’s pretty much the same thing, except you’re increasing the timer while the example in the other post decreases it.

If it’s still a bit much, let us know and we’ll explain it in more detail.

I’m sorry to be a pain but I’m definitely going to need a bit more detail. I’m now starting to feel more confused than when I started this thread! I really want this mechanic in my game, but I can’t seem to connect the variable with the timer.

this is definitely down to me and my own lack of knowledge. as I said before I’m only just starting to get my head around variables and they’ve been one element of Visual coding that I’ve really found quite challenging!

Hello I realy suggest to start with some tutorial videos - there are great ones from gdev team - check it: https://www.youtube.com/@GDevelopApp/videos

You can get lot of things working just by watching these tutors but whatsmore you will get better understanding of logic - how to create stuff in gdev.

Hello, it’s me again.

so I’ve made some progress but have stumbled into a roadblock again. I basically set up the timer as a variable. when the enemy is defeated, points do add onto the timer. But it’s not +20. It’s 90 and them + 20 (my countdown timer starts at 90.)

do you know how to get it so that it just adds the + 20?

Really appreciate your help and advice so far!

Logic seems fine to me. Recheck conditions - is the space on the end in the condition correct?

It’s working. You where right it was something to do with conditions.

Thank you so much for your help!

1 Like

Please mark the topic as [Solved] :slight_smile:

Just as an aside, in this action:

you don’t need to add -1. There is a subtract option, and you just subtract 1…

But as @radekpilmaier suggested, watch a few of the GDevelop beginner/basic tutorials. It’ll get you going faster, and probably introduce some new concepts for you to lpay around with.