- Home /
Question by
KukiKrunch · Jan 27, 2012 at 03:56 PM ·
triggerbooleanfalsetrue
Boolean problem!!
i have a boolean variable, and i want it to turn "true" when objectA is touching objectB, but turn to "false" when its not. my problem is that when they touch, it turns true, but it wont turn false again once they're not touching!!
im using " function OnTriggerEnter ".
Comment
Best Answer
Answer by Kryptos · Jan 27, 2012 at 04:51 PM
Basically, you need to check both enter and exit events.
void OnTriggerEnter( Collider other )
{
isTouching = true;
}
void OnTriggerExit( Collider other )
{
isTouching = false;
}
You may need to check the collider tag, name or layer to ensure these are the objects you expected.