Skip to content

Commit f9d5c7d

Browse files
authored
Create Light_Flirking
1 parent b6fa39e commit f9d5c7d

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

Light_Flirking

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
using System.Collections;
2+
using System.Collections.Generic;
3+
using UnityEngine;
4+
5+
public class Light_Flirking : MonoBehaviour
6+
{
7+
public bool IsFlickering = false;
8+
public float timeDelay;
9+
10+
void Update()
11+
{
12+
if (IsFlickering == false)
13+
{
14+
StartCoroutine(FlirkingLight());
15+
}
16+
}
17+
IEnumerator FlirkingLight()
18+
{
19+
IsFlickering = true;
20+
this.gameObject.GetComponent<Light>().enabled = false;
21+
timeDelay = Random.Range(0.01f, 0.1f);
22+
yield return new WaitForSeconds(timeDelay);
23+
this.gameObject.GetComponent<Light>().enabled = true;
24+
timeDelay = Random.Range(0.01f, 0.1f);
25+
yield return new WaitForSeconds(timeDelay);
26+
IsFlickering = false;
27+
}
28+
}

0 commit comments

Comments
 (0)