-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLightPulse.cs
37 lines (32 loc) · 920 Bytes
/
LightPulse.cs
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
31
32
33
34
35
36
37
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[RequireComponent(typeof(Light))]
public class LightPulse : MonoBehaviour
{
Light l;
[Header("Intensity")]
public bool pulseIntensity = true;
public float minIt;
public float maxIt;
public float itSpeed;
[Header("Range")]
public bool pulseRange = true;
public float minRange;
public float maxRange;
public float rangeSpeed;
// Start is called before the first frame update
void Start()
{
l = GetComponent<Light>();
}
// Update is called once per frame
void Update()
{
float t = Time.time;
if(pulseIntensity)
l.intensity = Mathf.PingPong(t*itSpeed, maxIt - minIt) + minIt;
if (pulseRange)
l.range = Mathf.PingPong(t*rangeSpeed, maxRange - minRange) + minRange;
}
}