How to handle the lack of unscaled time feature

Godot Version

v4.4.1.stable.official [49a5bc7b6]

Question

I’m wondering how everyone is handling the lack of unscaled_time feature in godot.

In my current project, I have:

  • UI effects, that needs to use real time (or unscaled_time)
  • Timers for 2DNode behaviors that needs to be scaled with game time scale.
  • Tweens for 2DNode movements that needs to be scaled with game time scale.
  • Animations for 2DNode that needs to be scaled with game time scale.

My current solution is, setting the Engine.time_scale same as game time scale. But I haven’t started on UI effects yet, so I think it’ll mess up that. My UI already has a LineEdit node and the caret blinking is effected by the Engine.time_scale, so it blinks very fast when the game speed is high.

Other solution is, setting a seperate game_speed variable. But then it requires changing/adjusting all other 2DNode timers, tweens and animations when game_speed is changed. It can be notified to the relevant functions by a game_scale_changed signal. And this looks like a big task and probably can cause errors, especially when the functions are in the middle of doing something.

I can’t think of anything else. Any ideas?

How about Time.get_ticks_msec() or Time.get_ticks_usec()?

Would it help ?

(methods to ignore time scale for both Tweens and Timers)

I suppose by default that those tweens/timers will use the Engine.time_scale by default. So you could set this to your game time scale, and your timers/tweens would respect your time scale, unless you want some of them to ignore this (with the methods mentioned above)

I would consider the engine time scale impacting the caret blinking frequency a bug

Thank you! I think this may solve my problem without changing the Game logic I implemented so far. I can use this option for UI animations.

Maybe it is. Luckily caret blinking speed is also an option. So I dynamically change it when Engine.time_scale is changed. It’s an acceptable workaround so far.

1 Like