Hi all! I’m working on a service-style game in GDevelop, and I want to implement a power-up that takes a few hours to recharge before it becomes available again.
How can I make the recharge timer continue even when the player closes the game? For example, if the power-up takes 3 hours to recharge and the player exits the game, I want it to be ready when they return after 3 hours.
What’s the best way to store and compare time so the timer syncs correctly when the game is reopened?
Thanks in advance!
Hey! There are 2 ways to approach this. The first way is through an offline time save. What you would do for this is when the power-up starts recharging, save what time it will be ready at, and save that in storage. Then just check every few seconds (or when they get back on the game) if their time is greater then the time saved. The only problem with that is players can cheat by changing their device time. The second way is through online time which I am not the best at, but I did create a tutorial to save the month so maybe it will be of some value to you?
[TUTORIAL] Month-Long Time Checker
Hopefully I helped in some way or another!
– Snowy
1 Like
Great tips! Thanks for the tutorial, I’ll definitely use it as a reference for my timer.
1 Like