Hi there. I want to Display text when my character touch game object and Disappear after 2 or 3 sec please Help......?
for detecting colisision o probably have to do something like this:
// put this into the caracter
function OnCollisionEnter (other : Collision) {
if (other.gameObject.tag == "Rock") {
// hits the rock
// for a countdown timer
// check this link
}
}
It's dependent on many factors. how do you want to display text. GUIText, GUI, 3d text ... if you use a OnGUI function so you should have a variable called display text
function OnGUI ()
{
if (display==true)
{
GUI.TextField (); //include arguments yourself
}
}
in your character collision event you should make this variable true for 2 seconds and then make it false. what do you use? collider/Trigger/character controller? if you use a collider with trigger checked so
function OnTriggerEnter (other : GameObject)
{
if (other.name="special gameobject") //check if you collided with the correct gameobject, you can check with it's name/tag
{
display==true;
yield WaitForSeconds (2);
display=false;
}
}