x


Help with my "speeding up time" script

Hi, I'm trying to get it so that my game speeds up faster and faster once the timer (which is counting downwards) reaches 30, and then goes back to normal timescale after the counter hits 1.

I have this script below so far but I have no idea what to put to increase the speed faster and faster, would it be Time.timeScale += 0.1f * Time.deltaTime i'm totally guessing here!?

#pragma strict
var countdownTimer : countdownTimer;

function Update(){

if (countdownTimer.seconds <=30){

//speed up time x2
Time.timeScale = 2f;

if (countdownTimer.seconds <=1){

//reset time to normal again
Time.timeScale = 1f;

}
}
}
more ▼

asked Jul 02 '12 at 08:34 PM

carter.carl30 gravatar image

carter.carl30
45 21 28 30

It worked, I should have tried it out first before posting the question hehe. MOD please delete if required, but I thought i'd post it in case it helps someone else

#pragma strict
var countdownTimer : countdownTimer;

function Update(){

if (countdownTimer.seconds <=30){

//gradually speed up time Time.timeScale += 0.1f * Time.deltaTime;

if (countdownTimer.seconds <=1){

//reset time to normal again
Time.timeScale = 1f;

}
}
}
Jul 02 '12 at 08:44 PM carter.carl30
(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

Pretty much.

if (countdownTimer.seconds <= 30) {
    // clamp at 2 (optional)
    if (Time.timeScale <= 2.0f) {
        Time.timeScale += 0.1f * Time.deltaTime;
    }
}
more ▼

answered Jul 02 '12 at 08:47 PM

KelsoMRK gravatar image

KelsoMRK
56 2

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

x5386
x793
x495
x141
x60

asked: Jul 02 '12 at 08:34 PM

Seen: 1038 times

Last Updated: Jul 02 '12 at 10:57 PM