let's say I have an explosion.
there's a centre of explosion (Vector3, point in space) and there's a sphere around it, with certain radius.
how to detect which objects in the scene are "inside" this sphere's radius?
let's say I have an explosion.
there's a centre of explosion (Vector3, point in space) and there's a sphere around it, with certain radius.
how to detect which objects in the scene are "inside" this sphere's radius?
Use Physics.OverlapSphere (as long as the objects you're interested in have colliders).
Basically:
if (Vector3.Distance(enemy.transform.position,explosion.transform.position)<radiusOfSphere){
// do stuff here
}
This will measure from the pivot of the target object, so you might not get a true if its center is outside of the sphere (even though part of it might be inside). You could also instantiate a spherical object and check for collisions (if everything else has colliders). It depends on how exact you want your explosion effect...