title: Unity3D - Using Time.deltaTime as wait time for a coroutine
body: <p>TL,DR: is it safe to use Time.deltaTime as the wait time for the yield in a coroutine?</p>
  
  <p>Often to avoid unnecessary logic inside Update() for short lived functionality I'll run a coroutine instead. For example in my game I have a slow coroutine that periodically checks the distance between NPCs and the player, if that distance is under some threshold I'll then run a more frequent coroutine with more expensive line of sight testing using raycasting etc. This seems much more efficient than checking everything constantly in Update().</p>
  
  <p>My question is this: is it safe to use Time.deltaTime as the wait time for the yield, thereby simulating Update() for the duration of the coroutine? i.e. <code>yield return new WaitForSeconds(Time.deltaTime);</code> </p>
  
  <p>Since deltaTime is not constant what happens if the next frame takes longer than the last - is the coroutine delayed until the next frame, or is something horrible happening like the whole frame being delayed until the coroutine finishes? I'm tempted to allow a buffer for safety e.g. <code>yield return new WaitForSeconds(Time.deltaTime * 1.2f);</code> but ideally I'd like it to execute precisely every frame.</p>