Legacy Documentation: Version 2018.1 (Go to current version)
  • C#
  • JS

Script language

Select your preferred scripting language. All code snippets will be displayed in this language.


Suggest a change


Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.


Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.



public static method OverlapSphere(position: Vector3, radius: float, layerMask: int = AllLayers, queryTriggerInteraction: QueryTriggerInteraction = QueryTriggerInteraction.UseGlobal): Collider[];
public static Collider[] OverlapSphere(Vector3 position, float radius, int layerMask = AllLayers, QueryTriggerInteraction queryTriggerInteraction = QueryTriggerInteraction.UseGlobal);


positionCenter of the sphere.
radiusRadius of the sphere.
layerMaskA Layer mask that is used to selectively ignore colliders when casting a ray.
queryTriggerInteractionSpecifies whether this query should hit Triggers.


Returns an array with all colliders touching or inside the sphere.

// Call a damage function on all objects caught in the
// radius of an explosion.
function ExplosionDamage(center: Vector3, radius: float) {
    var hitColliders = Physics.OverlapSphere(center, radius);

for (var i = 0; i < hitColliders.Length; i++) { hitColliders[i].SendMessage("AddDamage"); } }
using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour { void ExplosionDamage(Vector3 center, float radius) { Collider[] hitColliders = Physics.OverlapSphere(center, radius); int i = 0; while (i < hitColliders.Length) { hitColliders[i].SendMessage("AddDamage"); i++; } } }

Did you find this page useful? Please give it a rating: