- Home /
Help with skipping intro
I'm creating a game with an intro, but I want to have the option to skip the intro by pressing a button. I did some searching and found the best format for this would be if (Input.GetKeyDown("keyname") { whatever you want to happen }
But this isn't working. Specifically what I think is happening is that the "if" statement is being run right away, before I even press the button. What this means is that I'll try to load the intro and it will just go straight into the game. I don't know why this is. Could someone give me a suggestion?
Here's the code:
void Start () {
if (Input.GetKeyDown("enter"));
{
load ();
}
}
void load(){
SceneManager.LoadScene ("scene1");
}
Note: This is only my latest attempt at a fix, I've tried several other things like putting the LoadScene right in the "if" statement without making a whole other function. I also tried creating a variable that went from 0 to 1 when enter is pressed, and the scene is meant to load when this variable is 1. Both of these gave me the same result. Just thought I'd save some time to anyone who would have suggested those things.
Thanks in advance.
Start()
, as the name suggests, runs at the start. if you want to check at regular intervals, put the code in Update()
That doesn't seem to fix the problem, unfortunately.
Wait, never $$anonymous$$d! I just tried it again and it works now! Thanks so much!
Answer by Flaring-Afro · Jun 01, 2016 at 05:23 PM
Put the if statement in the Update method instead of Start.
Your answer
Follow this Question
Related Questions
Help In Making a SphereCast for 3D Tire! Working RayCast Script included! 0 Answers
How to use Input.GetAxis in if statement 1 Answer
Animation doesn't play on Input 1 Answer
Gui list and color 0 Answers
Why moveDirection.z doesn't work? 2 Answers