22 lines
453 B
C#
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);
|
|
}
|
|
}
|