- Home /
how to chick the time that passed when the game was closed
ok so im trying to make a game that runs even after its been closed on android but thats not possible i cant keep the game running in the background because it will automaticly close after 8 apps have been open i think thats how it works on my phone. so i have a veriable called health and i want to chick how much time has passed when the game has been closed then decrease the health based on that time any help
Answer by kolban · Apr 08, 2012 at 09:26 PM
It appears that one can use the System.DateTime.Now method to retrieve the current local time in real-world clock time. So, if for example, health is to decrease over real-world time even if the game is not running, you can use the real-world clock time as the indicator of how much health to remove. If I am to lose 10 units of health per hours and I stop playing my game at 9:00pm and restart playing at 9:00am the next day, then I would note that the last time I checked health was 12 hours (real-world) time and decrease my health by 12 hours * 10 units = 120 health units.
haha yes thats what i was thinking i just wanted to see if there was any other ways
Answer by NiteFlamesInc · Apr 08, 2012 at 10:48 PM
your could try making a var that holds the time in the games saved date that when that game starts again checks to see's how much time has passed and does the needed calulations
Your answer
![](https://koobas.hobune.stream/wayback/20220613070055im_/https://answers.unity.com/themes/thub/images/avi.jpg)