Turn on a light at night¶
Use a reactive Light response for lamps that follow the simulated Sun rather than a fixed hour. This also accommodates seasonal sunrise changes and polar conditions.
- Start with an initialized context containing Time, Calendar, and Astronomy, with valid profiles.
- Create a Point Light outside the sky's directional-light rig. Add
SystemBasedLightto the same GameObject. - Assign Context if the lamp is outside that context's hierarchy. Leave Automated enabled.
- Add one condition with source Astronomy, metric Daylight, and Invert enabled.
- Set Inactive Intensity to zero and Active Intensity to the desired lamp intensity. Choose a short fade in the response's shared settings.
- Enter Play Mode. Move simulated time between daylight and night; inspect target/applied influence and the Light intensity.
Expected result: influence approaches one when Astronomy reports no daylight, then returns toward zero in daylight. The fade uses scaled frame time; it is separate from the speed of the simulated clock.
For gradual dusk rather than a boolean daylight boundary, use Solar Elevation with a reversed numeric Ramp. A missing Astronomy system still yields zero; Invert does not turn a missing dependency into nighttime. Check ownership and initialization before adjusting the light.
Related: conditions, responses, astronomy.