Godot Version
4.3
Question
I have a function that freezes time for a specified amount of time:
func freeze(time: float) -> void:
_current_time_scale = Engine.time_scale
Engine.time_scale = 0
_freeze_timer = get_tree().create_timer(time, true, true, true)
await _freeze_timer.timeout
Engine.time_scale = _current_time_scale
_current_time_scale
and _freeze_timer
being declared outside of a function. I had this exact same code working before, then I retyped it and now it freezes for too long. It’s set to freeze for 0.2 seconds: freeze(0.2)
but it ends up freezing for well over 2 seconds. I used breakpoints to see if the time to wait was set correctly, and it was.
After continuing the breakpoint, it doesn’t pause for nearly as long. so it’s only when uninterrupted by breakpoints when it glitches out. What is causing this and how can it be fixed?