Exemplo n.º 1
0
    void Update()
    {
        if (flickerRate != 0)
        {
            time += Time.deltaTime;
        }
        if (Consistent)
        {
            rng = Mathf.Sin(time * flickerRate) * 50 + 50;
            if (time >= (2 * Mathf.PI) / flickerRate)
            {
                time = 0;
            }
        }
        else if (time > 1 / flickerRate)
        {
            time = 0;
            rng  = Random.Range(0, 100);
        }

        if (rng > flickerBalance)
        {
            BrightGoTo = startBright * Minimum / 100;
        }
        else
        {
            BrightGoTo = startBright;
        }

        bulb.intensity += (BrightGoTo - bulb.intensity) * Time.deltaTime * flickerHardness;


        if (jacobControl)
        {
            lightColor.SetColor(new Color(color.r, color.g, color.b, bulb.intensity / startBright));
        }
    }