- Home /
How to allow multiple reactions with hit.gameObject.tag
function OnControllerColliderHit (hit: ControllerColliderHit) // collision of character with floor { I have attached the script to the character
A floor surface in the game has been tagged with " floor"
now the problem is whenever my character walks on the area tagged " floor" everything displays perfectly and all the functions work BUT whenever i walk back on the area tagged "floor" there is no display because the previous reaction has already acknowledged "display" as false . how do i get it to always display whenever i walk on it . is there some sort of enter and exit function to check when the character leaves the area tagged "floor" ? thank you in advance :) oh and i just wrote this without testing it but i'm sure it should work fine =]
private var display = false;
var Closed : boolean = true; // check id "close" button is pressed
Closed = false ;
if (hit.gameObject.tag == "floor") //
{
display = true;
}
function OnGUI () {
if ( Closed ) { display = false ;}
if (display) {
GUI. Window (0, Rect (1,40,300,140), "blad blad blah ");
Closed = GUI.Toggle (Rect (1,60,300,20), "");
}
}
if (hit.gameObject.tag == "floor") //
{ Closed = false;
display = true;
} just reset Closed along with display
Your answer
![](https://koobas.hobune.stream/wayback/20220613074856im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Disable physics reaction 0 Answers
Leap motion: how to pickup a custom mesh 0 Answers
Why is my AI not thinking the collisions fast enough? 1 Answer
Problem with collision detection 0 Answers