Reply To: How would you slow this down so it doesn't flicker as quickly?

Forum Archive How would you slow this down so it doesn't flicker as quickly? Reply To: How would you slow this down so it doesn't flicker as quickly?

#23053
Nicholas Yang
Participant

    This can also be achieved with FixedUpdate(), right? Is there a rule for when to use FixedUpdate() and when to use Coroutines?

    public float timer = 0;
    public bool lightFlickering = false;
    
    void Update() {
        if (lightFlickeringOn) {
            lightBulb.intensity = Random.Range(1.5f, 1.9f);
            lightBulb.range = Random.Range(8, 15);
        }
    }
    		
    void FixedUpdate() {
        timer += Time.deltaTime;
        if (timer > 1.0f) {
            timer = 0;
            lightFlickeringOn = !lightFlickeringOn;
        }
    }