- Home /
run level for 4 minutes help
i want the level to run for 4 minutes and when there is 0 seconds left i want it to load game level called "main menu"
i was looking at the scripts in my project so i found the destroy on x amount of seconds
var lifeTime = 1.0;
function Awake () { Destroy(gameObject, lifeTime); }
so i through change the variable lifeTime to 1200 and then add in Application.LoadLevel("main menu"); which loads the level.
var lifeTime = 1200.0;
function Awake () {
Destroy(gameObject, lifeTime);
if (lifeTime ==0) Application.LoadLevel("main menu");
}
but nothing happens
Answer by Eric5h5 · Jun 09, 2011 at 12:39 AM
The reason nothing happens is because lifeTime will never be 0. There isn't any code which makes it decrease. Either use Invoke, or a coroutine with WaitForSeconds.
Your answer
![](https://koobas.hobune.stream/wayback/20220612101711im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Wait n-seconds before loading level 1 Answer
WaitForSeconds not (always) working on level startup 0 Answers
Script load level after few seconds, doesn't work. 2 Answers
Countdown Timer or WaitForSeconds? 2 Answers
Wait For Seconds to Load level C# 2 Answers