Problems with text timmers

Hello!

So, I have a problem here about GUI Texts. I’m developing a game where we have lots of interaction with items, and when it occurs, we must have a feedback text, just like “You grabbed the Basement Key”, or “The table has been turned upside down during the experiments”. Something like Silent Hill object and door interaction.
Well, to make it so each item had its unique text, I thought about creating an item script, which allows me to click it on my inventory, dropping it (and showing a respective text) and when I add it to my inventory, a feedback text is showed to tell the player it was acquired.
I created 2 text GameObjects in the item script to link the GUI Texts. I made the texts appear as following:

public var getObjectText:GameObject;
public var getobjectDrop:GameObject;

And to prevent them to start as active, I deactivated them on the Start function:

function Start()
{

	getObjectText.SetActive(false);
	getobjectDrop.SetActive(false);


}

When the object is obtained, its text becomes active.

function OnMouseDown()
{

	getObjectText.SetActive(true);

}

When it’s dropped, it’s drop text becomes active.

function BeDropped()
{

	transform.Translate(player.forward * 2);
	getobjectDrop.SetActive(true);

}

The problem is… how can I make my text disappear after two seconds without destroying it in both cases?
Thank you all in advance!

I’m not quite sure what you mean by destroying (so I apologize in advance ;)) but couldn’t you invoke a function on a timer that disables the text?

// Untested ;)

function OnMouseDown() {
    getObjectText.SetActive(true);
    Invoke("TurnTextOff", 2);
}

function TurnTextOff() {
    getObjectText.SetActive(false);
}

Let me know if I misunderstand :).

Hey! Its works! Thank you very much :smile: