A better flickering

public bool LightOn = false;

        public Light Light1;

        void Start()

        {

          Light1 = GetComponent<Light>();

            StartCoroutine(LightTimer());

        }

        

        // Update is called once per frame

        void Update()

        {

            Lighter();

        }


        void Lighter()

        {

            if (LightOn)

            {

                Light1.intensity = Random.Range(3, 5);

            }

        }

        IEnumerator LightTimer()

        {

            while(true)

            {

                LightOn = !LightOn;

                yield return new WaitForSeconds(0.5f);

            }

        }



This is the result. Can be slightly better if you play with the intensity and wait time.

  • Jonathan Gonzalez(jgonzalez) replied
    That's another way to approach it as well. I would probably randomize the wait time for the coroutine as well so it's not always at 0.5 seconds.