Get if no capsule colliders are colliding in a foreach statement.

I’m working on a game, it features a combat system, which the players stop, and lock into fight mode, they can run away clicking the right mouse button. I’m using a Radius detection method. If anyone can suggest a better way of doing it, go ahead. the problem is i don’t know how to detect if all capsule colliders are absent from the Array, excluding its own self. Since i have colliders below (Floors), it detects them as part of colliders, Which limits be being above to do a if(array = blank) statement. There’s another problem, i can’t disable raycasting on that floor layer as well, since it’s being raycasted by the mouse, and it spawns a image where the mouse was, and it disappears in half a second. I’ve tried tons of methods, if statements, game loops, but they all seem to not work, Still, since it detects its own collisions, that again, limits me more. Can someone help me on this? :slight_smile:

Collider[] hits = Physics.OverlapSphere(transform.position, radius);

        foreach (Collider hit in hits)
        {
            if (hit.GetComponent<CapsuleCollider>() != gameObject.GetComponent<CapsuleCollider>())
            {
                if (enemies && hit.tag == "Allies")
                {
                    inBattle = true;
                }
                else if (allies && hit.tag == "Enemies")
                {
                    inBattle = true;
                } // Do something here if it doesn't detect any Capsule Collisions (Excluding itself)
            }
        }

Are you using layers? You can set up which layers collide which other layers. So you can have colliders for ground on one layer, and colliders for fighting on another.