Game type runner, issue with a Time lag

Hello, I’m currently working on a game type runner (c#), for that, I need a perfect timing about the proc of different obstacles / buffs. Or the timing isn’t that perfect. (I really doubt it’s a problem relative to my code)

For exemple, I have some obstacles who must proc every 3 seconds starting from 1,5s, so I should have something like this
;

P_obst1 at 4.5s
P_obst2 at 7.5s
P_obst3 at 10.5s ect…

In reality it is;

P_obst1 at 4,534961s
P_obst2 at 7,566661s
[…]
P_obst8 at 25,74396 (when it should be at 25,5s)

At 25 secondes there is already 0,25s decall, maybe it seems little, but in a very fast game like mine, we can see that time lag (who’s more and more in function of time) visually, and we can fell it in the gameplay.

I’ll really appreciate if you can help me with that, thx !

Yeah, the length of a frame is variable. I’d be shocked if Time.deltaTime ever lined up with an exact time. That’s why I tend to do stuff like this instead:

public float m_procTime;

void Update()
{
  if (Time.time >= m_nextProcTime)
  {
    Proc();
    m_nextProcTime += m_procTime;
  }
}

private float m_nextProcTime;

Now pausing the game can cause headaches, but we actually use a GameTime wrapper class here that acts like the Time class but will stop if the game is paused.