x


How does Time.timeScale affect time?

Does unity keep track of system time, and then multiply it by timeScale to define Time.time, and, derivately, Time.deltaTime? If a frame took, say, 0.016 actual seconds, if timeScale were set to 0.5, Time.deltaTime would give 0.032? I know that different timeScale values are used for slow motion and speed ups, but I need to make sure how exactly it is implemented.

more ▼

asked Feb 03 '10 at 11:49 PM

Micha Lewtak 2 gravatar image

Micha Lewtak 2
183 7 7 9

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

2 answers: sort voted first

time.deltaTime and time.time are functions of timeScale and unity multiplies them with timeScale. as you said if one frame takes 0.1 as deltaTime and if timeScale is 0.5 then you'll get 0.05 as deltaTime. in this way unity can makes all framerate independent code faster or slower. keep in mind that it will affect time.time too. also FixedUpdate and it's fixedDeltaTime is a function of timeScale too and if you set time.timeScale to 0 then you'll have no FixedUpdate executed every second. if you want to know what variables are depending on timeScale, documentation says

Except for realtimeSinceStartup, timeScale affects all the time and delta time measuring variables of the Time class.

more ▼

answered Feb 04 '10 at 03:49 AM

Ashkan_gc gravatar image

Ashkan_gc
9.1k 33 56 117

I see. Well now I realized that even if I wasn't sure of this, I could always implement my own slomo multiplier...

Feb 04 '10 at 06:17 AM Micha Lewtak 2
(comments are locked)
10|3000 characters needed characters left

Use this script:

function Update () {
    print (Time.deltaTime);
}

Run that, observe the numbers, change timeScale as desired, run again, compare results.

more ▼

answered Feb 04 '10 at 12:39 AM

Eric5h5 gravatar image

Eric5h5
80.3k 42 132 521

(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:

x573
x85

asked: Feb 03 '10 at 11:49 PM

Seen: 2732 times

Last Updated: Feb 03 '10 at 11:49 PM