# Timer

The code below is an example of a simple countdown timer. The code would need modified to be useful in the LevelManager.  The timer uses a co-routine that pauses 1 second between each repeat. &#x20;

//modified ,based on Code from:[https://www.noob-programmer.com/unity3d/countdown-timer/ ](https://www.noob-programmer.com/unity3d/countdown-timer/)

```java
using System.Collections;
using UnityEngine;
using UnityEngine.UI;

public class CountDown : MonoBehaviour {

  public int timeLeft = 60; //Seconds Overall
  public Text countdown; //UI Text Object
  void Start () {
    StartCoroutine("LoseTime");
    Time.timeScale = 1; //Just making sure that the timeScale is right
  }
  void Update () {
    countdown.text = ("" + timeLeft); //Showing the Score on the Canvas
  }
  //Simple Coroutine
  IEnumerator LoseTime()
  {
    while (true) {
      yield return new WaitForSeconds (1);
      timeLeft--; 
    }
  }

} //end class
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://kdoore.gitbook.io/cs2335/mini-game_proj4/timer.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
