I want to know if an object is currently "lit", so I want to detect if the light source hits it.
I thought of a trigger as big as the light but I think that it would be quite annoying to put a specific collider for every light (I would need to modify the collider to adapt it to other light "shapes"). Is there a way / a better way than mine?
Yes, your way is probably the best way depending on how accurately you want to detect if an object is lit.
Vector2.Distance
method to see whether the object's center is within Light.range
of the light's center.Light.range
again.If you have many different, or even randomly generated, light shapes, you could create a script that, in the Awake
method, sets the collider's size/shape automatically.