Some games have “daily reward” things for logging every 24 hours, I was wondering how would someone go about making this in a unity game. Like since there is no way to run a script while the game isn’t running would I have to setup a http python server with a timer and link that to unity or something else…?
There’s 2 good ways to do this:
Make a server. Have a database store accounts and last access times. Compare the current time to last accessed, and if it passes, replace it with the new time. Pros: can’t be cheated. Cons, costs money, requires internet.
Use the built in time function. Don’t ask me how, but there’s a way to access a phones internal clock through Unity. Simply have the game hard save the last accessed time, and regardless of if its closed or not, you’ll still have that there to compare against the phones internal time. A phones internal clock never stops, even when it dies. Pros: No server, no internet, no problem. Cons: It’s not that hard to change the time on a phone…