Create an accurate Countdown

while (GameSetup.countdown == true) {
GameSetup.Ctimer -= Time.deltaTime ;
if (GameSetup.Ctimer <= 1.0f)
GameSetup.countdown = false;
Debug.Log(GameSetup.Ctimer);
}

Im trying to create a timer that counts down from 3 to 1 and then the game starts. in my main script I have Ctimer = 4 with a gui that shows it count down in real time. At first glance this seem to work but then I actually timed it with a timer its like 2.1 seconds instead. I tested it out with yield return new WaitForSeconds(3f); and the 3 seconds on that is longer and more accurate .This code isn’t in an update function as i heard update should be avoided if you can and the game is set to a Application.targetFrameRate = 60;The frame-rate stays between 60 and 75 ish. I don’t know if that affects anything or not

Here’s how I’d do it.

using UnityEngine;
using System.Collections;

public class MoveObjectWithButton : MonoBehaviour {

	public bool startCountinDown = false;
	public int deltaTimeSecond = 1 * Time.deltaTime;

	void Update(){
		if (startCountinDown) {
			StartCoroutine(Timer());
				}
	}
	IEnumerator Timer(){
		Debug.Log ("3");
		yield return new WaitForSeconds(deltaTimeSecond);
		Debug.Log ("2");
		yield return new WaitForSeconds(deltaTimeSecond);
		Debug.Log ("1");
		yield return new WaitForSeconds(deltaTimeSecond);
		startCountinDown = false;

	}
}