x


how many times a second time.time will update and what source of this does it use?

how much is the precision of time.time? how many times a second does unity update it? what source of time unity uses for it's timing? high performance CPU time. multimedia timer? that old assembly instruction? i know that only unity engineers can answer this question.

more ▼

asked Jan 22 '10 at 12:27 PM

Ashkan_gc gravatar image

Ashkan_gc
9.1k 33 56 117

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

1 answer: sort voted first

As the documentation states:

The time this frame has started (RO). This is the time in seconds since the start of the game.

So, depending on whether you are in FixedUpdate or Update, Time.time is updated as often as the screen updates, or in Time.fixedDeltaTime increments.

If you need more precision, use Time.realtimeSinceStartup. That function is based on the Microseconds() function on OS X, and on the QueryPerformanceCounter() function on windows.

more ▼

answered Jan 22 '10 at 12:59 PM

jonas echterhoff gravatar image

jonas echterhoff ♦♦
9.7k 7 23 102

so can i use time.time in a coroutine to see if i spend much time then wait for the next frame?

Jan 23 '10 at 10:13 AM Ashkan_gc

yes, since coroutines will only be called once per frame/ fixed frame, Time.time will work as expected there. But why don't you just use "yield return new WaitForSeconds(x);"?

Jan 23 '10 at 02:46 PM jonas echterhoff ♦♦

i want to see how much time past since start of current frame. can use time.time for it? does it return 0 before next Update/FixedUpdate?

Jan 24 '10 at 04:58 AM Ashkan_gc

You should use start = Time.realtimeSinceStartup at the beginning of your iteration, and then check Time.realtimeSinceStartup-start at any time to see how much time has passed.

Jan 24 '10 at 02:16 PM jonas echterhoff ♦♦
(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:

x5058
x660
x571

asked: Jan 22 '10 at 12:27 PM

Seen: 2323 times

Last Updated: Jan 22 '10 at 01:00 PM