Timer across scenes triggering at random intervals

I’m new to game dev so this is a problem I have no idea how to approach, but what I need is a timer that works across scenes and triggers at different times.

Explaining it in the games terms I think makes it easier to understand: You are in your room on the computer and your mom can walk in at different times (telegraphed by a knocking noise) if you are in the computer scene at the moment the noise is finished something will happen (haven’t decided yet). But if you aren’t caught, the timer resets.

Sorry if this is hyper specific and asking too much! Once again, I’m new and I really need the help. Much appreciated :sparkles:

Hi Dr Goat,

Definitely an interesting question. As far as I know there is no global timer and I don’t believe having an object set as global will have it’s timer persist between scenes.

I think one of the ways you can tackle this is using a global variable to track your time instead. The most simplest way to achieve this would be a scene timer in each of your scenes that increases the global variable.
If you’re going to choose this option, I’d suggest a lower timer interval then 1 second and then divide the global variable by X to get your seconds.
Only having the timer run every second might lead to situations where the timer was at 0.9/1.0 seconds and you change scenes essentially losing 0.9 seconds.