JiNanCementPlantForUnity/Assets/3rdParty/Environment/DIY_Cave_Environment/TorchLight.cs

22 lines
453 B
C#

using UnityEngine;
[RequireComponent(typeof(Light))]
public class TorchLight : MonoBehaviour
{
public float minIntensity = 0.25f;
public float maxIntensity = 0.5f;
float random;
void Start()
{
random = Random.Range(0.0f, 65535.0f);
}
void Update()
{
float noise = Mathf.PerlinNoise(random, Time.time*5);
GetComponent<Light>().intensity = Mathf.Lerp(minIntensity, maxIntensity, noise);
}
}