x


Time.time explanation.

Can you explain how to use Time.time, how it work?

more ▼

asked Jan 05 '10 at 09:31 PM

user-297 (google) gravatar image

user-297 (google)
584 22 27 36

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

Time.time simply gives you a numeric value which is equal to the number of seconds which have elapsed since the project started playing.

The value is a 'float', which means that you get exact time including the fraction of the second which is currently elapsing, rather than discrete whole-number seconds.

Time.time is useful for many purposes, and it's often used when comparing the current time against a time stored in a variable, to check how much time has elapsed since a certain moment, or how much time remains until a certain future moment.

A common mistake is to use Time.time as the 3rd parameter for a 'Lerp' function. When using Lerp, you would usually need to use Time.deltaTime instead.

Time.time never changes during the course of a function, so you cannot use it to profile code that takes place inside a single function. Time.time (and Time.deltaTime) only change their value once per frame.

For more information, see the Time.time manual page, and the Time Class manual page which - if you click on each function or property of the class - has examples of how to use each of these things.

more ▼

answered Jan 05 '10 at 09:50 PM

duck gravatar image

duck ♦♦
41.4k 95 152 415

When you say Time.time and delta time does not change during a function call, does that include realTimeSinceStartup too? You have given this answer in some other threads too but you never say anything about Time.realTimeSinceStartup.

Jan 05 '10 at 10:18 PM TowerOfBricks

The main difference betweeen Time.time and Time.realTimeSinceStartup is that the latter is not effected by Time.timeScale. In other words: If you have Time.timeScale = 0.1F, when Time.realTimeSinceStartup = 10F, Time.time would be 1F (10 seconds in "real time" would be equivalent to 1 second of "game time").

Jan 06 '10 at 07:30 AM jashan

Time.realTimeSinceStartup DOES change during a function call.

Jan 06 '10 at 04:33 PM runevision ♦♦
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x5269
x587
x86

asked: Jan 05 '10 at 09:31 PM

Seen: 6396 times

Last Updated: Jul 21 '11 at 11:32 PM