So Basically I have two colliders which display GUI.
One is on my door/lever, once you reach close enough it displays “Press e to open”.
Once you leave the trigger, it sets drawGUI = false;
Now I have a bigger trigger collider for the entire zone which is for a tutorial ground.
I walk to said zone, the GUI displays.
Now if I walk up to the lever, both of these GUI display properly.
However if I walk out of the lever zone, it erases BOTH GUI that I have, instead of just the one.
How would I erase just the one, as opposed to the other?
Here is the code for my door/lever.
#pragma strict
var theDoor : Transform;
var theLever : Transform;
private var drawGUI = false;
private var doorIsClosed = true;
//var LeverCollider = false;
function Update ()
{
if (drawGUI == true && Input.GetKeyDown(KeyCode.E))
{
changeDoorState();
}
}
function OnTriggerEnter (theCollider : Collider)
{
if (theCollider.tag == "Player")
{
drawGUI = true;
//LeverCollider = true;
}
}
function OnTriggerExit (theCollider : Collider)
{
if (theCollider.tag == "Player");
{
drawGUI = false;
// LeverCollider = false;
}
}
function OnGUI ()
{
if (drawGUI == true)
{
GUI.Box (Rect (Screen.width*0.5-55, 35, 110, 25), "Press E to Open");
}
}
function changeDoorState()
{
if (doorIsClosed == true)
{
theLever.animation.CrossFade("Pull");
theDoor.animation.CrossFade("Open");
doorIsClosed = false;
yield WaitForSeconds (3);
theDoor.animation.CrossFade("Close");
doorIsClosed = true;
}
}
and here is the code for my tutorial zone
#pragma strict
private var drawGUI = false;
var TrainingGroundsLevel = 0;
var GUIBool = false;
function OnTriggerEnter (theCollider : Collider)
{
if (theCollider.name == "BeginningCollider")
{
TrainingGroundsLevel = 100;
//drawGUI = true;
GUIBool = true;
}
if (theCollider.name == "TrainingGroundsIntroCollider")
{
TrainingGroundsLevel = 1;
//drawGUI = true;
GUIBool = true;
}
if (theCollider.name == "TrainingGroundsTreesCollider")
{
TrainingGroundsLevel = 2;
//drawGUI = true;
GUIBool = true;
//Debug.Log("Working");
}
/*
if (GUIBool == true)
{
drawGUI = true;
Debug.Log("Working");
}
*/
}
function OnTriggerExit (theCollider : Collider)
{
if (theCollider.name == "BeginningCollider");
{
//drawGUI = false;
GUIBool = false;
TrainingGroundsLevel = 0;
}
if (theCollider.name == "TrainingGroundsIntroCollider");
{
//drawGUI = false;
GUIBool = false;
TrainingGroundsLevel = 0;
}
if (theCollider.name == "TrainingGroundsTreesCollider");
{
//drawGUI = false;
GUIBool = false;
TrainingGroundsLevel = 0;
}
}
function OnGUI ()
{
if (GUIBool == true && TrainingGroundsLevel == 100)
{
//drawGUI = true;
GUI.Box (Rect (0, 50, 250, 250), "MY CONTROLS AND INTRODUCTION TEXT HERE.");
}
if (GUIBool == true && TrainingGroundsLevel == 1)
{
//drawGUI = true;
GUI.Box (Rect (0, 50, 250, 250), "Other training text here");
GUI.Box (Rect (Screen.width*0.5-105, 10, 210, 25), "Training Grounds - Intro");
}
if (GUIBool == true && TrainingGroundsLevel == 2)
{
//drawGUI = true;
GUI.Box (Rect (Screen.width*0.5-105, 10, 210, 25), "Training Grounds - Trees");
}
}
Thank you for the quick reply. Well it is erasing, it's keeping the other one drawn that I want to do. Once I leave the lever collider or press e, it erases the other "TrainingGroundsIntroCollider" "TrainingGroundsLevel == 1" Should the one lever/door script affect the other one? Is it a "global" GUI? Because how I see it where it says
– UNDEADMANBEARPIGfunction OnGUI () { if (GUIBool == true && TrainingGroundsLevel == 100) { //drawGUI = true; GUI.Box (Rect (0, 50, 250, 250), "Blah Blah"); } }As long as GUIBool is true and TrainingGroundsLevel == 100 it should be displaying this GUI, right?