I have a game and when a certain amount of time passes that it will load the level. Any help would be great.Thanks
You can do this in several ways. One of them is by using Time.time, but that measures time passed since the start of the game, not the start of the current level. I’d probably do something like this:
var timeOut : int = 20;
//time until level loads
function Awake()
{
Invoke("LoadLevel", timeOut);
}
function LoadLevel()
{
Application.LoadLevel("insert level name here");
}
Hope it helps!
You could have a counter in the FixedUpdate() function, but I’m not sure how easy it would be to make sure you’re getting the right minutes/seconds. Here’s another way:
var counter : int;
var maxCount : int;
function Start()
{
counter = 0;
InvokeRepeating("checkTime", 0, 30);
}
function checkTime()
{
//The counter counts in 30 second intervals. If you want to have it do something every
//5 minutes, you'd set the maxCount to 10.
counter++;
if(counter >= maxCount)
{
//The counter is just right, do something!
counter = 0;
Application.LoadLevel("Level42");
}
}
On this page you have three different ways from simple timer to invoke function.
You can choose the one you understand the best or you can learn new way.
http://answers.unity3d.com/questions/307337/how-do-i-change-the-scene-when-my-timer-reaches-ze.html