0 votes

I want that after every 24 hours, the user will get a new task, for example kill 10 Aliens or shoot 700 bullets. How to do?

in Engine by (377 points)

1 Answer

0 votes
Best answer

Store the current time in a variable. Then check that variable by subtracting it from the current time.

https://docs.godotengine.org/en/stable/classes/class_os.html?highlight=get_time#class-os-method-get-date

by (856 points)
selected by

But the user could easily change the date and time in the settings and the game would think 24 hours are over, right? I want the player to wait real 24 hours.

That is true, but there are many (high profile) games that people have enjoyed that can be tinkered with in that way.

If you don't want it to be possible for the player to tinker with the value you will need to be operating a separate server which is used to calculate the time and store the variable.

As with most things in game development, it may make sense to go with a simple solution for now and then evaluate if you need to replace it later with a network call to a server.

Alright, thanks.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.