okay so i have an hit box (isTgigger) i want to make it so that when my player hits the box a GUI text appears on screen, displaying some information, the text is removed upon the player ceasing contact with the hit box. i have a code wich i don’t know if will work or not.
function OnTriggerEnter (other : Collider) {
#inser code for printing info on screen here#
}
can some1 help me?
Keep track of if something is within the trigger with a boolean. Then if that boolean is true, display the GUI :
var withinTrigger : boolean = false;
function OnTriggerEnter (other : Collider)
{
withinTrigger = true;
}
function OnTriggerExit (other : Collider)
{
withinTrigger = false;
}
function OnGUI()
{
if ( withinTrigger )
{
GUI.Box( Rect( (Screen.width * 0.5) - 100, 10, 200, 25 ), "Within the Trigger !" );
}
}