x


Application.Loadlevel

I have a game and when a certain amount of time passes that it will load the level. Any help would be great.Thanks

more ▼

asked Aug 25 '12 at 02:42 AM

Tim A gravatar image

Tim A
205 5 16 27

(comments are locked)
10|3000 characters needed characters left

3 answers: sort voted first

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!

more ▼

answered Aug 25 '12 at 07:11 AM

AutoFredrik gravatar image

AutoFredrik
156 3

(comments are locked)
10|3000 characters needed characters left

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");
     }
}
more ▼

answered Aug 25 '12 at 07:00 AM

Sequence gravatar image

Sequence
68 5 6 7

(comments are locked)
10|3000 characters needed characters left

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

more ▼

answered Aug 25 '12 at 07:13 AM

fafase gravatar image

fafase
10.5k 9 15 41

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

x297
x263

asked: Aug 25 '12 at 02:42 AM

Seen: 859 times

Last Updated: Aug 25 '12 at 07:13 AM