Hello. I have a problem where a gameObject is not detected.
This is the code from that gameObject and it tried to destroy other gameObject like him if there are more:
private void DestroyExtraRoomConectors()
{
Collider2D[] colliders = Physics2D.OverlapPointAll(transform.position,5);
foreach (Collider2D collider in colliders)
{
Debug.Log(collider.gameObject.tag);
if (collider.gameObject.CompareTag("RoomConector"))
{
if (gameObject.GetInstanceID()<collider.gameObject.GetInstanceID()) Destroy(collider.gameObject);
else Destroy(gameObject);
}
}
}
This is the GameObject inspector:
The Debug.Log just shows other GameObjects that are not in the layer 5, and that’s strange.
Is more information needed?