-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLightBlink.cs
More file actions
30 lines (26 loc) · 794 Bytes
/
Copy pathLightBlink.cs
File metadata and controls
30 lines (26 loc) · 794 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
using UnityEngine;
namespace Assets.PrototypingKit
{
public class LightBlink : MonoBehaviour
{
[Range(0, 1.0f)]
public float lightMaxIntensity;
[Range(0, 1.0f)]
public float lightMinIntensity;
private Light light;
public float speed;
private void Start()
{
light = GetComponent<Light>();
light.intensity = light.intensity + (Random.Range(-0.1f, 0.1f));
if (lightMaxIntensity < lightMinIntensity)
{
lightMaxIntensity = lightMinIntensity;
}
}
private void Update()
{
light.intensity = ((Mathf.Sin(Time.time * speed) + 0.5f) * (lightMaxIntensity - lightMinIntensity)) + lightMinIntensity;
}
}
}