I have a large collider that can overlap several other GameObjects with colliders at once. This means that sometimes OnTriggerExit2D is called even if I’m still colliding with another GameObject. I’ve tried using OnTriggerStay2D instead of Enter, and while that is better, it still gets 1 frame of OnTriggerExit being called every time I exit a GameObjects collider.
How can I make sure that while my Object is colliding with something, it will stay in that state, and not change state until it is completely collision free. i.e Using the code below, how can “isColliding” stay true until no GameObjects are overlapping the collider?
private void OnTriggerStay2D(Collider2D collision) //or OnTriggerEnter2D
{
isColliding = true;
}
private void OnTriggerExit2D(Collider2D collision)
{
isColliding = false;
}
Edit: If using a Raycast you can just do “if(collider == null)”, is there something similar I could use here?