Load level on button press not working - new scene loads instantly without pressing key

Hi! Sorry for the newbie question - I’ve looked around but I just can’t work out why this is happening:

I’ve attached the below script to a game object in my title scene, and want the main scene to load if either of the 4 arrow keys are pressed.

But as soon as I open the title scene, the main scene loads immediately after, without any keys being pressed!

If anyone can help - it will be so much appreciated!!

function Update () {

if ((Input.GetKeyDown(KeyCode.UpArrow) == true));

else if ((Input.GetKeyDown(KeyCode.DownArrow) == true));

else if ((Input.GetKeyDown(KeyCode.LeftArrow) == true));

else if ((Input.GetKeyDown(KeyCode.RightArrow) == true));




Application.LoadLevel (1);

}

Laurien

Your “if” statements have no bodies, so regardless of the condition they will continue to the rest of the function.

Try

if (Input.GetKeyDown(KeyCode.UpArrow) || 
    Input.GetKeyDown(KeyCode.DownArrow) || 
    Input.GetKeyDown(KeyCode.LeftArrow) || 
    Input.GetKeyDown(KeyCode.RightArrow)) {

    Application.LoadLevel(1);
}