Other
How to write : If the player don't play the game in 24 hours, the game is over
I make the virtual pet game, and want to add game over.
If the player leavers the pet in 24 hours, the screen goes black and game over.
So what should I write If the player don't play the game in 24 hours, the game is over (the screen goes black) ?
Answer by s_awali · Dec 02, 2018 at 02:15 PM
Before the player quit the game, save the current date with DateTime.now. How to save this value is up to you: player prefs, binary formatter, etc (See this tutorial https://unity3d.com/fr/learn/tutorials/topics/scripting/persistence-saving-and-loading-data).
Then, when the game start, check the difference between the saved date, and the current date, using (datevalue1 - datevalue2).TotalHours > 24.
Follow this Question
Related Questions
Time Management. Morning, noon and night. 2 Answers
Get Internet Year PHP 0 Answers
Getting the time from a server 2 Answers
Adding Coyote Time and Jumpbuffer gave player infinite jumps. 1 Answer