- Home /
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;
}
}
}
It worked, I should have tried it out first before posting the question hehe. $$anonymous$$OD 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;
}
}
}
Answer by KelsoMRK · Jul 02, 2012 at 08:47 PM
Pretty much.
if (countdownTimer.seconds <= 30) {
// clamp at 2 (optional)
if (Time.timeScale <= 2.0f) {
Time.timeScale += 0.1f * Time.deltaTime;
}
}
Your answer
Follow this Question
Related Questions
falling faster after time 1 Answer
Pause button 2 Answers
Control animation speed with slider 4 Answers
Increase ball speed by time 1 Answer
Javascript Timescale Problem 0 Answers