Trouble with Real world time
I want to write a script in which my player will have a specific amount of life which resets after a day or it gets 1 life back after every hour. How do I achieve that? I also want it in such a way that players can't get around with it by changing the time in their phone. Please help
Answer by LeeJBaxter · Jun 28, 2018 at 11:56 AM
Do you need the life to reset at 12:00am, or when the player has actually played the game for 24 hours. In other words, should it reset each day even if the player isn't actually playing it?
If you only want time to pass by whilst the player is actually playing the game, I would keep a reference to the time passed in a variable, which is then saved when the player exits the game and loaded when they start it again. That way, you're not referencing the clock in any way.
In all honesty, I wouldn't worry about it too much; unless cheating saves them real money, I don't think the players of your game are going to go to the extreme of changing the time on their phone just to cheat in the game!
yes indeed cheating will prevent them from making inapp purchase. I want extra life to add as inapp purchases. I have to use internet time but I don't know how to.
yeah I want to use a server based time but I don't know how to
Your answer
![](https://koobas.hobune.stream/wayback/20220612165628im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Change brightness of display on Android 1 Answer
How to change camera on Android? 1 Answer
Unity C# Android Gyro - Wrong Orientation 2 Answers
Trouble with closing Unity 5 ads 0 Answers