Game speed control

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Thummper

Hi,

I’ve seen this question: https://forum.godotengine.org/4616/any-way-to-manipulate-time-scale

I’m trying to add time controls to my game and have working pause, play, and fast forward buttons, but setting Engine.time_scale also affects my animation speed - I have some animations on screen and on my HUD that I don’t want to be affected.

Is there any way to use Engine.time_scale without affecting my animations, or is there a better method of time control I could use?

:bust_in_silhouette: Reply From: johnygames

I see two ways you can go about this:

  1. The easier method involves setting the speed of the animations according to the engine’s time scale, e.g. double animation speed if time slows down to 1/2 of normal speed. This is a property you can set via the AnimationPlayer node and I’m sure the same must hold true for HUD elements too.

  2. The more difficult option would be to not use Engine.time_scale at all. Instead, create variables that act as speed factors for all your movements in game. Then multiply movements speed by said factors to achieve the desired result. For example, if a kinematic body moves with a speed of Vector3(2, 0, 0), increase the speed by multiplying it by a factor of 2 when time speeds up or decrease it by multiplying by a factor of 0.5 when time slows down.

Seems like the best solution for me would be the second option. I really like the ease of using Engine.time_scale, but I still need my animations to play when the game is paused.

Thummper | 2020-08-13 14:04