I’m working on an intro scene for my project and i’ve gotten everything working the way i want, just a couple final details to work out.
I’m coming from an art background, so scripting is pretty difficult for me to understand so bear with me.
First,here’s my script to exit the intro screen and start the game
var mySound : AudioSource;
function Update () {
if (Input.GetButtonDown ("Start")) {
mySound.Play();
animation.CrossFade ("SceneFadeOUT");
Application.LoadLevel ("TestLevel1");
}
}
What i’m unable to achieve is disabeling the input on “start” for 3 seconds, and secondly i need a delay between
animation.crossfade (“SceneFadeOUT”)
Application.LoadLevel (“TestLevel1”);
i’ve been trying different things for the past day or so to no avail. I’ve read into WaitForSeconds, but i’m unsure how to implement it in my script since it wont work alongside an Update function…
Sorry for the beginner questions, but i’m in need of some help here. Thanks!
You can’t put WaitForSeconds in Update. Make a function loading your level, put the WaitForSeconds the that function. In Update, call that function when you click on the button, it will work.
I’m not a Javascript guy, but from what I have seen…
var isLoading = false;
OnUpdate(){
if (isLoading == false)
{
if (Input.GetButtonDown ("Start")) {
mySound.Play();
isLoading = true; }
else
{
//Do nothing, because we are waiting for the scene to transition
}
}
This isn’t the most optimized way to do things, but since it is your loading screen, there is not a huge need to get crazy.