- Home /
onControllerColliderHit reaction
Ok I am having a serious problem having a GUI window displayed if my object hits another object . the object to be hit is shown here as scienceblock if science block is hit then i want a GUI window displayed . i have tried adding the function but it just wont work
This is the code
private var scblock= false;
function OnControllerColliderHit (hit: ControllerColliderHit) {
//-----------------------------------------------------
if (hit.gameObject.tag == "scienceblock")
{
scblock= true;
}
}
//------------------------------------------------
function LateUpdate () { if (scblock) {
// i want a GUI window displayed if the panel is hit
panel = false ; } }
Answer by Berenger · Feb 05, 2012 at 05:42 PM
I think your boolean scblock works almost as you wish it to. Just disable it when it stops touching the desired objects (don't forget to ignore the ground).
But you're not displaying the window ever, or else it is elsewhere in your code. If that's the issue, I suggest you check out the GUI.Window doc.
Yeah -- hit is probably working, and display part broken. Easy way to check: make scblock public and watch it in the Inspector.
Your answer
![](https://koobas.hobune.stream/wayback/20220613063751im_/https://answers.unity.com/themes/thub/images/avi.jpg)