# OverlapSphere(Vector3, float, int, QueryTriggerInteraction)

> Computes and stores colliders touching or inside the sphere.

## Definition

* **Type:** Method
* **Namespace:** [UnityEngine](/engine/6000.5/script-reference/unityengine.md)
* **Assembly:** UnityEngine.PhysicsModule

```csharp
public static Collider[] OverlapSphere(Vector3 position, float radius, int layerMask, QueryTriggerInteraction queryTriggerInteraction)
```

### Parameters

**** (\[Vector3]\(/engine/6000.5/script-reference/unityengine/vector3)): Center of the sphere.**** (\[float]\(https\://learn.microsoft.com/dotnet/api/system.single)): Radius of the sphere.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): A Layer mask defines which layers of colliders to include in the query.**** (\[QueryTriggerInteraction]\(/engine/6000.5/script-reference/unityengine/querytriggerinteraction)): Specifies whether this query should hit Triggers.

### Returns

| Type                                                                    | Description                                                        |
| ----------------------------------------------------------------------- | ------------------------------------------------------------------ |
| [Collider\[\]](/engine/6000.5/script-reference/unityengine/collider.md) | Returns an array with all colliders touching or inside the sphere. |

### Remarks

Additional Resources: [Physics.AllLayers](/engine/6000.5/script-reference/unityengine/physics/alllayers.md). Allocates memory. Consider using [Physics.OverlapSphereNonAlloc](/engine/6000.5/script-reference/unityengine/physics/overlapspherenonalloc.md) instead.

```csharp
using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour
{
    void ExplosionDamage(Vector3 center, float radius)
    {
        Collider[] hitColliders = Physics.OverlapSphere(center, radius);
        foreach (var hitCollider in hitColliders)
        {
            hitCollider.SendMessage("AddDamage");
        }
    }
}
```

Additional Resources: Ray cast with layers section of [ Use of layers in Unity](/engine/6000.5/manual/working-with-gameobjects/layers/use.md).
