-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathLight_Flirking
More file actions
28 lines (26 loc) · 755 Bytes
/
Light_Flirking
File metadata and controls
28 lines (26 loc) · 755 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
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Light_Flirking : MonoBehaviour
{
public bool IsFlickering = false;
public float timeDelay;
void Update()
{
if (IsFlickering == false)
{
StartCoroutine(FlirkingLight());
}
}
IEnumerator FlirkingLight()
{
IsFlickering = true;
this.gameObject.GetComponent<Light>().enabled = false;
timeDelay = Random.Range(0.01f, 0.1f);
yield return new WaitForSeconds(timeDelay);
this.gameObject.GetComponent<Light>().enabled = true;
timeDelay = Random.Range(0.01f, 0.1f);
yield return new WaitForSeconds(timeDelay);
IsFlickering = false;
}
}