Files
2026-05-05 21:01:16 -05:00

31 lines
642 B
C#

using UnityEngine;
// Very simple script, just takes a light on start and slowly fades it to 0
// over the duration specified.
[RequireComponent(typeof(Light))]
public class FadingLight : MonoBehaviour
{
Light lightObj;
public float duration;
public bool isFading;
float timer;
float startIntensity;
void Start()
{
lightObj = GetComponent<Light>();
startIntensity = lightObj.intensity;
}
void Update()
{
timer += Time.deltaTime;
float t = timer / duration;
t = Mathf.Clamp01(t);
lightObj.intensity = Mathf.Lerp(startIntensity, 0, t);
}
}