-
-
Save r2d2m/dba5359bb96f539d55272986d76820b3 to your computer and use it in GitHub Desktop.
Revisions
-
LotteMakesStuff created this gist
Jun 16, 2021 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,42 @@ using UnityEngine; public class Flicker : MonoBehaviour { public string LightStyle = "mmamammmmammamamaaamammma"; private Light light; public float loopTime = 2f; [SerializeField] private int currentIndex = 0; private float lightTimer; void Start() { light = GetComponent<Light>(); } void Update() { char c = GetNextChar(); int val = c - 'a'; float intensity = (val / 25f)*2; light.intensity = intensity; } private char GetNextChar() { lightTimer += Time.deltaTime; var step = loopTime / LightStyle.Length; if (step < lightTimer) { lightTimer -= step; currentIndex++; if (currentIndex >= LightStyle.Length) currentIndex = 0; } return LightStyle[currentIndex]; } }