I have currently two levels ready to build. I have the loevels loaded into Build Settings panel. I understand the Loadlevel script, but I don’t know what to attach it to to have it function. Also, what is the syntax that I can add to the script to add time to the loadLevel script? I would like my splash screen to stay up for 3 seconds.
I’m sorry for being so ignorant… Where do I put/attach the LoadLevel script? I do not need a collision. Just a splash/credits screen and enough time to read it and then load the simulation immediately following that. Thanks again everyone.
A timer would be what I would like. Or even better a keystroke. Something akin to ‘press spacebar to start’ as gui text over the credits screen. Thanks Targos!
Thanks. I have created an empty GameObject and attached your script. I changed the code like below. I wasn’t sure what the “GarysLevel2OrWhatever”(is this the scene name? i.e. MyTest1.unity) code would have been referring to… Could I use the value of 1 like below. It doesn’t give an error but it doesn’t work either.
var myGui: GameObject;
function Start () {
myGui.active = false;
if (Input.GetButtonDown (“Jump”));
myGui.active = true;
Application.LoadLevel(1);
}
Thanks. I apologize it still doesn’t work. No error in the console. Here is what I have. In the Build Game panel I have my assets checked and listed as follows:
I updated the code as you suggested. When I execute the Build and start the application, the spacebar does not load the level 1 object and have the Gui splash screen disappear. Thanks for any further help.
To which game object did you attach the script?
Is the game object in the first level?
Btw. you can also preview level loading in the editor. Just open the first scene you dragged in the build player dialog as the first level. Then hit play.
I don’t need a fade out on this, it could work but I do not understand the code for (this) and for (!Input.GetButtonDown(“StartArena”)). Fadeout is very cool though.
I just timed the splash screen to loading Level 1 and it is roughly 4 seconds. This is ok but I don’t understand why the spacebar function isn’t working…
Would I replace my code with yours or append it to it in some fashion?
oh ok, sorry - that’s just what i was using which was modified from the FPS tut.
DontDestroyOnLoad (this); is just saying “don’t kill the object this script is attached to when loading a new level”
the !Input line is just saying while (whatever your chosen button is) is not pressed, don’t do anything, if i understand it correctly. its just another way to do it i guess. putting your above code in an update function should work as well like joachim said. the code i posted has other stuff in it not applicable(the loading function) i just showed that for example.
i think maybe your best bet is to post the script your working with. (is what you posted above it?)
active = false should be in start as below (you don’t need to set that every frame). this should work, i’m not really a good coder i think someone else might have to help you. the only other thing i can think of is your jump button is not mapped correctly or there was something changed in the load level script.
try commenting out all the myGui stuff from your script and see if it works. it looks to me like myGui is referencing itself, which i think is wrong, i.e you’re turning the scipt off at start (i think ; )
//var myGui : GameObject;
function Start ()
{
//myGui.active = false;
while (!Input.anyKeyDown)
yield;
Loading();
}
function Loading ()
{
//myGui.active = true;
Application.LoadLevel(1);
}
EDIT AGAIN: oh i think i see, is the gameobject with the load script your GUI object as well? if so move the load script to a different empty gameobject name it “loader” or something, and click on it, then drag your gui gameobject into the script variable.