- Home /
I am trying to make a door, when using this script nothing happens.
I applied this script to a collision box with is trigger checked, it is meant to pop up a message saying "press E to enter", when E is press it is to simply bring you to the next scene however when I make the character walk into the collision box, nothing happens, please help.
#pragma strict
var theDoor : Transform;
private var drawGUI = false;
var Scene : int = 0;
function Update ()
{
if (drawGUI == true && Input.GetKeyDown(KeyCode.E))
{
Application.LoadLevel(Scene);
}
}
function OnTriggerEnter (theCollider : Collider)
{
if (theCollider.tag == "Player")
{
drawGUI = true;
}
}
function OnTriggerExit (theCollider : Collider)
{
if (theCollider.tag == "Player")
{
drawGUI = false;
}
}
function OnGUI ()
{
if (drawGUI == true)
{
GUI.Box (Rect (Screen.width*0.5-51, 200, 102, 22), "Press E to open");
}
}
Comment
Your answer
Follow this Question
Related Questions
Loading a scene in game with a GUI 1 Answer
How do you select a root object from a child's script? 1 Answer
Open door = load scene c# issues 4 Answers
terrain wont come up in scene 0 Answers
Scene restarting problem 0 Answers