Most efficient way to find closest

So here’s the story. I have a large number of enemies that can be hurt by any light source. All light sources have the same tag “Light”
I need to check the enamy’s distance from the closest Light. There will be a lot of lights and a lot of enamies looking for the lights every update. So is there a faster way of finding the closest “Light” with out having to search the FindGameObjectsWithTag array?
I’ve considered the Physics SphereCast, but again I would have to go through an array of stuff each time.

I think your best bet is something like Physics.OverlapSphere:

Have it only collide with things on the “Lights” layer, and iterate over the array. Use Sphere collides on the lights to make it as fast as possible, and it will be very fast.

What I think you are getting at is called spacial partitioning. Octrees are commonly used as the partitioning algorithm: Octree - Wikipedia The physics system uses spacial partitioning, and a million other insanely complicated math tricks to make the collides fast.

well you could optimize static lights because you know there position won’t change
All static light locations could be stored in a global/static array.

Enemies should also only be checked if they moved.
if there rigidbodies that is if there velocity isn’t zero.
otherwise you’ll have to store there position for a frame and compare against it the next.

moving lights should also have there position stored and only updated if they move.

also Are you sure you actually need to check its distance from every light?
at a certain point cant you just say your not close enough to any light for me to care?
(spherecast and if nothing I could care less)
Give me some more information.