Go through door, by loading next scene, with key-press

Hi. First, I want to say that I really suck, at scripting, and that’s why I’m trying to learn it.

Now to the question. I’m trying to make it possible to go to a house, but I wanted it so, if you come near the door, a small press E will pop-out, and when you press E, next scene will load.

Could someone please tell me how to do that?

Sorry, if I have some misspellings there.
Also, I’m not trying, to make the door open with animation.

1 Answer

1

Well, I searched a bit through the answers, and found the solution. The script must be like this:

var levelToLoad;

function OnTriggerEnter (other : Collider) {
    //Check to see if a player entered the door.
    if (other.gameObject.CompareTag("Player") && Input.GetKey(KeyCode.E)) {
        Application.LoadLevel(levelToLoad);
    }
}  //This code is not mine, It is from burnumd