system
1
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
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.