Physics.OverlapSphere

static function OverlapSphere (position : Vector3, radius : float, layerMask : int = kAllLayers) : Collider[]

Description

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

NOTE: Currently this only checks against the bounding volumes of the colliders not against the actual colliders.

JavaScript
    // 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 example : 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++;
}
}
}

import UnityEngine
import System.Collections

class example(MonoBehaviour):

def ExplosionDamage(center as Vector3, radius as single):
hitColliders as (Collider) = Physics.OverlapSphere(center, radius)
i as int = 0
while i < hitColliders.Length:
hitColliders[i].SendMessage('AddDamage')
i++