Good to hear you've made something that works. Nice simple solution, too.

I'll fix mine up and we can compare soon. Not until after Wednesday, though.

This formula does work:

fade_factor = ( fade_end - temp_distance) / ( fade_end - fade_start );

Example:

fade_start = 423;
fade_end = 967;

current distance from player (temp_distance) = 423

(967 - 423) / (967 - 423) = 1

Perfect, the light will be full on at 423 quants from the player


(967 - 967) / (967 - 423) = 0

Perfect, the light will be off


The values will continue to increase/decrease beyond that, so you just have to clip the value from going outside that range