Is there any way to detect light in Unity? I want to set up a system whereby enemies will continually spawn in dark areas. The player can place lighting objects (torches, make campfires etc) so ideally I'd like to write code that detects the actual light and only spawns at a certain distance away. Alternatively I could set it up so that it detects the objects rather than the light itself.
I would like it so the monsters can spawn anywhere where it's dark and not limit myself to having to set up gizmos at specific spawn points.
How would people recommend I go about this?
Are your lights static, or do they move around? If they're static, you can set up a bunch of predefined "spawn points" around your level that are inherently in darkness. If you have a lot of lights that move around, I'd probably suggest setting up some kind of grid-based system with nodes. When a node is within a light's range, disable it from being an active spawn point. When you want to spawn only check the active nodes.
If the player has their own light source, do a distance check based on the light from the player...
The easiest way would be to use point lights, create a List object of all lights that you want to detect and do something like this:
public class Player: MonoBehaviour
public bool InTheShadows()
foreach(GameObject L in Lights)
if((transform.position - L.transform.position).magnitude < L.light.range)