- Home /
Trouble with Load Level
hello :),,, i have wrote a code out but it doent work,, im not a very good coder so i could tell what was wrong with it This is the code
function Update ()
{
if(Application.WaitForSeconds == 10)
{
Application.LoadLevel("Kino_Dar_Zona");
}
}
What i wanted was for my splash screen to wait 10 seconds and then load a level automaticly,,, sorry for the stupid code that dosent make sence but im learning still so im just testing things out.. if anybody could help me fix this code or tell me another code that would work then that would be great
Thanks
I know this wasn't actually part of your question, but I think it's worth noting that you might be missing the point of splash screens. Users don't want to wait 10 seconds if they can help it! You should begin loading the level and display a splash screen for the time it takes to do the loading. That way the user is less likely to become bored while waiting for the next level.
Of course I realize that there may be some important information that you are showing in the splash screen or there may be some other important reason for making the user wait 10 seconds - I just felt the need to make this point for potential viewers of this question.
Answer by GoSuNeem · Oct 29, 2011 at 07:39 AM
You can also add something in the Awake() or Start()
http://unity3d.com/support/documentation/ScriptReference/MonoBehaviour.Invoke.html Invokes are pretty sweet ;]
function Awake() { Invoke("LoadNewScene", 10); }
function LoadNewScene() { Application.LoadLevel("Kino_Dar_Zona"); }
This Worked nicely, :D Thank you so much :) and thanks for this link it will help me with loads more things, I shouldn't have to ask as much questions now. :)
Thanks again.
Answer by Graham-Dunnett · Oct 26, 2011 at 03:49 PM
Try this:
function Update ()
{
yield WaitForSeconds (10);
Application.LoadLevel("Kino_Dar_Zona");
}
sadly it doesnt work :( it says in the debug box Script error: Update() can not be a coroutine. Any idea's ??
Yes, just don't put it in update.
Like Graham's code but not in the Update() function.
function NewLevel()
{
yield WaitForSeconds (10);
Application.LoadLevel("$$anonymous$$ino_Dar_Zona");
}
Like I said, try...
function Awake() { Invoke("LoadNewScene", 10); }
function LoadNewScene() { Application.LoadLevel("$$anonymous$$ino_Dar_Zona"); }
All this would do is that when the code loads up it'll wait 10 seconds then it'll run the "LoadNewScene" function. which is just "Application.LoadLevel("$$anonymous$$ino_Dar_Zona");"
Your answer
Follow this Question
Related Questions
How to attach Animation to other objects in script? 1 Answer
Attack Animation Trigger 1 Answer
Could anyone help me with this weapon script? 1 Answer
Walking Motion 1 Answer
Create a Sprite Animation Clip in Code 3 Answers