Time.time or Time.deltaTime for Game's Internal Timer

I’m using Time.time to get the seconds since the game loaded, and calculating minutes, hours, and days with it. But I read Time.time varies depending on the performance of the computer.

Is that only frame rate related, or is it something I need to worry about it, since my game depends so much on an internal clock?

I also have gameObjects (characters) that run on their own internal clocks, which hopefully I’ll be able to use to calculate their “age”.

Thanks all.

You can use real time to calculate against…

 float currentMinute = System.DateTime.Today.Minute;

If you want the time to be exactly the same as the real time it would be easier. However if you want to just get the time since the start you could just store the starting time and calculate against that.

System.DateTime.Today works down to milliseconds.

I’m calculating from the start of the game. Thought Time.time would work…and it is, but I was wondering if my method was an efficient one. This is how I’m doing it:

void Update () 
	{
		if(isTimeRunning == true)
		{
			mainSeconds = Time.time;
			
			seconds = mainSeconds  % 60;
			minutes = (mainSeconds / 60) % 60;
			hours	= (mainSeconds / 3600) % 24;
			days	= (mainSeconds / 86400) % 336;
			weeks  	= (mainSeconds / 604800) % 48;
			months  = (mainSeconds / 2419200) % 12;
			years 	= (mainSeconds / 29030400);	
		}
	}

From what I understand that is completely fine. Since Time.time returns the seconds since the start of the game… However it seems like if you do mess with Time.timeScale it will effect this time. Which probably isn’t bad if your doing like a day cycle or something and the player pauses the game.

Sounds like you’d be better off with the Stopwatch class.

–Eric

I don’t know about effeciency, but it would probably be more understandable (and thus more maintainable) to use System.TimeSpan to do all the calculations.