(Solved) Variable value reducing by 1 every x seconds

Hi, I’ve looked through the forums and the only response I can find is back in 2014 and GDevelop looks very different!

I have a power bar that I want to reduce every 10 seconds. Under actions I’ve added

  • Wait 10 seconds
  • Change the global variable -1.
    But what happens is it waits 10 seconds then continuously repeats the change in variable. I thought if I create a sub action and state ‘Do it once’, this would fix this, but it doesn’t. I’d appreciate and guidance. Sorry of this is obvious. I’m trying to go through all the video tutorials, but sometimes I miss bits!

Hey Steve, I’d use a timer. The wait action doesn’t truly wait. It only pauses that event and its subevents but the other events continue including the paused event until it hits Wait again. So, unless you used a Boolean or other condition, it would just keep looping and you’d have a “buffer” full of wait actions which would expire in sequence like a traffic jam. One for every frame.

Timers and time [GDevelop wiki]

Thanks Keith. On the wait function, I can’t see an ‘equal to’, only greater or less than, so can I ask, how do I set it to 10 seconds for example? Or is ‘Greater than’ sufficient?

Wait event? I’m not sure where you’re seeing an equals. I would use a timer.

The “Wait X seconds” action [GDevelop wiki]

Thanks Keith. That makes sense. It was just on the Condition side where it shows “>3 seconds”.
Thanks so much for your help :smile:

1 Like