GUI.Box that will appear for 3sec

I’m trying to make a GUI.Box appear for 3 seconds, when entering a Collider (For like Zones and such).
But i seem to not be able to understand the timer.
Here’s what i’ve got so far:

var guiOn : boolean;
var guiSkin : GUISkin;
var zoneName : String;
var size : Rect = Rect(0,0,100,100);
var textTimer : float = Time.deltaTime * 2;
static var deltaTime : float;


function Start () {



}

function Update () {

if(textTimer==2){
textTimer +1;
}

}

function OnTriggerEnter(theCollider : Collider) {

	guiOn=true;
	
}

function OnGUI () {
	
	GUI.skin = guiSkin;
	
	if(guiOn) {
		GUI.Box(size,zoneName);
	}
}

I’m still trying to make it work myself, but it would be AWESOME with some help :slight_smile:

Basically you need to reset your timer at trigger enter, increase it inside Update, and display text if it is less or equal than 3 seconds. So something like this:

function Update() {
    if(textTimer <= 3) {
        textTimer += Time.deltaTime;
    }
}
 
function OnTriggerEnter(theCollider : Collider) {
    textTimer = 0;
}

function OnGUI() {
    if(textTimer <= 3) {
        GUI.Box(size,zoneName);
    }
}