and how am i supposed to use this? It gives me an error
Assets/explosion.js(6,23): BCE0024: The type ‘UnityEngine.GameObject’ does not have a visible constructor that matches the argument list ‘(int)’.
you could also do it very similarly to the solution I gave you in your other thread:
var allObjects = FindObjectsOfType(GameObject);
for (var go : GameObject in allObjects) {
var distanceToMe : float = Vector3.Distance(transform.position, go.transform.position);
if(distanceToMe < range)
//add to array here
}
But overlapsphere is probably more efficient. If you’re trying to do an explosion, you should check out the explosion script in the fps tutorial on unity3d.com, it’s pretty useful, because it covers things like applying explosion forces, mathematically varying damage amount based on distance to explosion center, and applying physics to dead replacement objects in the event that the explosion reduces an enemy’s health to zero.