title: Unity C# timer should trigger function every 1.5 min but doesn't
body: <p>I'm trying to write a script that turns all lights off after 1.5 minutes for 10 seconds, then turns them back on.<br>
  Right now, it seems like the timer is getting bypassed. I realize that the reason for this is probably because the time will never be exactly 90 or so.<br>
  That being said, I have no idea how to get the result I want.   </p>
  
  <p>I thought of using <code>InvokeRepeating</code> instead (as commented out) but then that would mean that the lights would be off longer every time.</p>
  
  <pre><code>using System.Collections;
  using System.Collections.Generic;
  using UnityEngine;
  
  public class LightsTimerTrigger : MonoBehaviour {
      private GameObject[] allLights;
      private float time = 0.0f;
      private float secondTimer = 0.0f;
  
      void Start () {
          // Create array of lights 
          allLights = GameObject.FindGameObjectsWithTag("riddleLights");
  
          //InvokeRepeating("lightsOn", 60.0f, 120.0f);
          //InvokeRepeating("lightsOff", 60.10f, 120.10f); // Exponential
      }
  
      // Update is called once per frame
      void Update () {
          time += Time.deltaTime;
  
          if(time%90 == 0)
          {
              secondTimer = time;
              lightsOff();
              Debug.Log("Lights off");
          }
  
          if (time == secondTimer + 10)
          {
              // Turn lights back on after 10 seconds
              lightsOn();
              Debug.Log("Lights back on");
          }
      }
  
      void lightsOff()
      {
          foreach (GameObject i in allLights)
          {
              i.SetActive(false);
          }
      }
  
      void lightsOn()
      {
          foreach (GameObject i in allLights)
          {
              i.SetActive(true);
          }
      }
  }
  </code></pre>