- Home /
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.
Answer by webik150 · Mar 23, 2013 at 08:28 AM
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
Your answer
Follow this Question
Related Questions
Scene Change OnCollision Not Working 2 Answers
Private and public variables 2 Answers
How to make a double sliding door? 1 Answer
Is it possible to create a hole for a door in a wall-like cube? 2 Answers
Cloud recognition in Vuforia 0 Answers