- Home /
How to work a real life timer?
What I am trying to do is bring basically real time into my game, but for it to "keep track" after the game is closed. The timer is going to be set for 30 minutes and after 30 minutes "blah blah" will happen, but if the player ends the game and starts up later it will show the new time, let's say the timer is set and going and the player ends the game at 29 minutes and gets back on after 27 minutes and the timer's new time will be 2 minutes remaining and continuing to count but if the player gets back 30+ minutes something will happen. The only timer I know how to do is the normal timer that restarts after the game is restarted.
Unity 5.3.1 Personal
Script: C#
Answer by Addyarb · Jul 12, 2016 at 02:50 AM
Greetings,
Check out a nifty C# class called DateTime.
You'll need to import the 'System' namespace in order to use this.
So, at the very top of your script, type:
using System;
Next, try this:
void Start()
{
Debug.Log(System.DateTime.Now.ToString());
}
From here I'm sure you can figure out a way to set a timer.
Best of luck!
Your answer
Follow this Question
Related Questions
Timer counting UP instead of DOWN 1 Answer
How to transfer time script to 24 hours and not decimals 1 Answer
How to make a Time Based Score? 1 Answer
Timer doesn't work properly 2 Answers
Game Timer help needed 2 Answers