My OnTriggerExit2D is being called even though the collider has been destroyed. I’d like a way to check whether the colliding object has been destroyed or not. Is there any way to do this short of adding a bool to my colliding object?
Code:
private void OnTriggerEnter2D(Collider2D collision)
{
Destroy(collision.gameObject);
}
private void OnTriggerExit2D(Collider2D collision)
{
// collision.gameObject != null -- Doesn't work
// collision.gameObject.activeSelf -- Doesn't work
Debug.Log("OnTriggerExit2D is being triggered on a destroy");
}