title: Delay before a specific action in OnTriggerStay()
body: <p>I'm making a 3d-shooter in Unity. I want to let player nail up windows and doors so that he had a cover. Holes in the walls like windows and doors already have inactive boards on them. I'd like to have the player hold the button when he's near the window to set a board active. So, if it is required to nail down three boards to completly shut up the window, the player has to be near the window and hold a button, for instance, for 10 seconds to place one board. Same for the second and third boards. This process, however, can be interrupted and the window can have only one or two boards nailed down. Windows have invisible triggers that detect player's presence.</p>
  <p>Here's the code attached to windows:</p>
  <pre><code>using System.Collections.Generic;
  using UnityEngine;
  
  public class ActivateBoards : MonoBehaviour
  {
      public float delay = 10f;
      public List&lt;GameObject&gt; boards;
      private int currentAmount = 0;
      private int totalAmount;
      private float elapsed = 0f;
      // Start is called before the first frame update
      void Start()
      {
          totalAmount = boards.Count;
      }
  
      // Update is called once per frame
      void Update()
      {
  
      }
  
      private void OnTriggerStay(Collider other)
      {
          if (other.gameObject.CompareTag(&quot;Player&quot;) &amp;&amp; Input.GetButtonDown(&quot;Fire1&quot;) &amp;&amp; currentAmount != totalAmount)
          {
              elapsed += Time.deltaTime;
              if (elapsed &gt;= delay)
              {
                  boards[currentAmount].SetActive(true);
                  currentAmount++;
                  elapsed = 0;
              }
          }
      }
  }
  </code></pre>
  <p>I tried to use a coroutine but it's a no go since the player can release the button right in the middle of <code>yield return new WaitForSeconds()</code> command. Also, I'd like to attach a UI image that would play a role of a progress bar and fill up as time goes by. I don't really get along with time in Unity - the code above doesn't work at all. And I suppose that <code>Time.deltaTime</code> only works well in <code>Update()</code> method? I need fuctionality from <code>OnTriggerStay()</code> to detect player and functionality from <code>Update()</code> to count time. How can I achieve it?</p>