Files
kronic 5a59d8e14f Add Synty asset packs (enemies + environment/FX/UI) via Git LFS
14 newly-imported Synty Polygon packs (~2.46 GB; FBX/PNG/textures stored in
Git LFS per .gitattributes). Enemy-grade characters: Werewolf, Kaiju,
FantasyHeroCharacters, Vikings, Western, HorrorCarnival, Dog. Environment:
Nature, NatureBiomes, PNB_Core, FantasyKingdom. UI/icons: Icons,
InterfaceCore, InterfaceSciFiSoldierHUD.

Werewolf + Kaiju back the DR-023 animated enemies; the rest are cataloged
for future work in Docs/Vault/06_Roadmap/Synty_Asset_Inventory.md.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-06 23:28:47 -07:00

71 lines
1.9 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class FlickerLight : MonoBehaviour
{
public Light lightAsset;
// min max intensities
public float minIntensity = 1.25f;
public float maxIntensity = 2f;
public float flickerSpeed = 3.75f; // Speed of the flickering effect.
public float smoothingFactor = 9f; // Controls the smoothness of intensity changes.
private Coroutine flickerCoroutine;
private float targetIntensity;
void Start()
{
//check if there is a light
if (lightAsset == null)
{
//attempt to get light transform if none is defined
lightAsset = GetComponent<Light>();
{
//disable script if nothing is found
if (!lightAsset)
{
Debug.LogError("No Light Source Detected, Disabling Script: " + transform.name);
enabled = false;
return;
}
}
}
flickerCoroutine = StartCoroutine(ambientLight());
}
IEnumerator ambientLight()
{
while (true)
{
//random initial target intensity
targetIntensity = Random.Range(minIntensity, maxIntensity);
float elapsedTime = 0f;
float startIntensity = lightAsset.intensity;
while (elapsedTime < 1f)
{
lightAsset.intensity = Mathf.SmoothStep(startIntensity, targetIntensity, elapsedTime);
elapsedTime += Time.deltaTime * smoothingFactor;
yield return null;
}
//time to wait before next flicker target
yield return new WaitForSeconds(Random.Range(0.05f, 0.2f) / flickerSpeed);
}
}
//stops coroutine if disabled in scene
void OnDisable()
{
if (flickerCoroutine != null)
{
StopCoroutine(flickerCoroutine);
}
}
}