Use OnTriggerExit2D when an object leaves a trigger collider. You should **not** just set onHand = false; You will need to check if the GameObject that left is tagged "Hand" because any other GameObject that has collided with the trigger and left will set onHand to false, but the GameObject tagged "Hand" could still be colliding.
void OnTriggerExit2D ( Collider2D other )
{
if ( other.gameObject.tag == "Hand" )
{
onHand = false;
}
}
↧