wip : lighting theater
This commit is contained in:
@@ -19,7 +19,10 @@ namespace Unheimlich.VFX
|
||||
|
||||
private float _randomOffset;
|
||||
|
||||
void Start()
|
||||
[Header("Glitch Object")]
|
||||
public GameObject glitchObject;
|
||||
|
||||
void OnEnable()
|
||||
{
|
||||
_randomOffset = Random.Range(0f, 1000f);
|
||||
StartCoroutine(FlickerRoutine());
|
||||
@@ -32,27 +35,38 @@ namespace Unheimlich.VFX
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
float t = Mathf.PerlinNoise(Time.time * flickerSpeed + _randomOffset, 0f);
|
||||
ApplyFlicker(t);
|
||||
if (flickerSpeed > 0f)
|
||||
{
|
||||
float t = Mathf.PerlinNoise(Time.time * flickerSpeed + _randomOffset, 0f);
|
||||
ApplyFlicker(t);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (targetLight) targetLight.intensity = 0f;
|
||||
}
|
||||
|
||||
if (Random.value < glitchChance)
|
||||
if (Random.value < glitchChance * Time.deltaTime)
|
||||
yield return StartCoroutine(GlitchBurst());
|
||||
|
||||
yield return null;
|
||||
}
|
||||
}
|
||||
|
||||
private IEnumerator GlitchBurst()
|
||||
{
|
||||
float elapsed = 0f;
|
||||
float duration = Random.Range(glitchMinDuration, glitchMaxDuration);
|
||||
|
||||
if (glitchObject) glitchObject.SetActive(true);
|
||||
|
||||
while (elapsed < duration)
|
||||
{
|
||||
ApplyFlicker(Random.value);
|
||||
elapsed += Time.deltaTime;
|
||||
yield return null;
|
||||
}
|
||||
|
||||
if (glitchObject) glitchObject.SetActive(false);
|
||||
if (targetLight) targetLight.intensity = 0f;
|
||||
}
|
||||
|
||||
private void ApplyFlicker(float t)
|
||||
|
||||
Reference in New Issue
Block a user