I have two GameObjects tagged "Point", each with a Collider 2D set to Is Trigger
.
I have another GameObject, "pencil", which also has a Collider2D set to Is Trigger
I want to move the pencil the first point to the start drawing a line, and then stop drawing when it hits the second point.
My problem is that when the pencil hits a point, it calls OnTriggerExit2D
multiple times. How can I only detect first contact with the point?
Pencil script:
private void OnTriggerExit2D(Collider2D collision)
{
if (!collision.isTrigger)
{
if (collision.gameObject.tag == "Point")
{
writing = !writing;
}
}
}