- Home /
OnTriggerExit2D doesnt work
I know this question have been asked many times, but i havent found an answer yet. So i thought ill just ask. The problem is OnTriggerExit2D doesnt work. But OnTriggerEnter2D works. I have no idea how to fix it, in my movement script i tried delete the transform.localscale (I reed that it doesnt work when u use that) But it didnt work either.
This is my script:
#pragma strict
var hidepress = false;
function Start () {
}
function Update ()
{
}
function OnTriggerEnter2D(other: Collider2D)
{
if(other.gameObject.tag == "Hide")
{
hidepress = true;
Debug.Log("hide is on");
}
}
function OnTriggerExit2D(other: Collider2D)
{
if(other.gameObject.tag == "Hide")
{
hidepress = false;
Debug.Log("hide is off");
}
}
why don't you try with a straight debug? like avoiding the if statement?
function OnTriggerExit2D(other: Collider2D) {
hidepress = false; Debug.Log("hide is off");
}
so you can see if the problem is another...
I think you're doing something wrong, like testing the collision on two colliders under the same gameobject... Try using OnTriggerStay, and look closer at what's happening...
Forgot to mention that i have done it. $$anonymous$$y problem is solved!
Your answer
![](https://koobas.hobune.stream/wayback/20220613140907im_/https://answers.unity.com/themes/thub/images/avi.jpg)