Invert Physics.OverlapSphere

How do i check if my player is NOT inside the Physics.OverlapSphere Radius? i can only make it work when im inside the raidus??

aggroLayerMask is set to Player, and my player has the “Player” layer

withinAggroColliders = Physics.OverlapSphere(transform.position, 30, aggroLayerMask);
        if (spawning)
        {
            currentTime -= Time.deltaTime;
            if (currentTime <= 0 && withinAggroColliders.Length > 0 )
            {
                Spawn();
            }
        }

Search the array of colliders, if the query isn’t found, it’s not present.

If the player character is the only thing on the Player layer you’d want to find, you could skip searching the array, and just check the length of the collider array.

If the player character is the only object you’d want to find, forget using physics and just get the distance between the position of the player and this object.

ok any tips on how to check the distance? :stuck_out_tongue: not so good here

Vector3.Distance should work, just make sure to account for the radius of the player (ie: if the player is 5 units away, but fills approximately a 3x3 box, then they’re still touching a 4-unit radius circle).