I was looking an official example for coroutines in Unity here.
However, when I call WaitAndPrint the time taken is never exactly 5 seconds.
IEnumerator WaitAndPrint()
{
float timeStart = Time.time;
yield return new WaitForSeconds(5);
Debug.Log(string.Format("Time taken = {0}", Time.time - timeStart));
}
if (Input.GetKeyDown(KeyCode.R))
StartCoroutine(WaitAndPrint());
Instead, it varies around 5.003133.
This is most likely down to the frame rate, which makes me wonder how can I make sure that a coroutine takes the precise amount of time it should take despite the fluctuating frame rate?