Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an option for tweens to ignore Engine.time_scale #11404

Closed
tvenclovas96 opened this issue Dec 21, 2024 · 0 comments · Fixed by godotengine/godot#100735
Closed

Add an option for tweens to ignore Engine.time_scale #11404

tvenclovas96 opened this issue Dec 21, 2024 · 0 comments · Fixed by godotengine/godot#100735
Milestone

Comments

@tvenclovas96
Copy link

tvenclovas96 commented Dec 21, 2024

Describe the project you are working on

A strategy game that can be sped up on command by the player. Engine.time_scale is updated in conjunction with Engine.physics_ticks_per_second to maintain a constant in-game simulation speed while the game speeds up/slows down in real life.

Describe the problem or limitation you are having in your project

Most things are affected by changing Engine.time_scale, which is desirable - such as in-game animations changing speed to match the rest of the game. However many elements, notably UI, need to maintain a "constant" real life speed and ignore Engine.time_scale.

Tweens are fantastic for dynamically animating UI elements, but are affected by Engine.time_scale. While the tween speed can be "normalized" by setting its own speed scale to 1.0 / Engine.time_scale, this doesn't account for changes to Engine.time_scale after it has been created. In a game with lots of UI where game speed is constantly being adjusted by the player, this is very noticeable.

SceneTreeTimer is a "set and forget" object similar to tweens, and it already has an option to ignore Engine.time_scale when created, allowing it to be used for constant time delays no matter the game speed.

Describe the feature / enhancement and how it helps to overcome the problem or limitation

Add a Tween.set_ignore_time_scale(ignore: bool) option that will allow it to ignore Engine.time_scale, which will be disabled by default (tween is affected by the time scale). This would allow use of tweens for constant time animations no matter the game speed.

I'm prepared to implement this feature if it's received positively.

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

I'd expect Tween.set_ignore_time_scale(ignore: bool) to work similarly to set_speed_scale(speed: float) where it would affect all appended tweeners and can be changed during the tween's lifetime. The two functions would work in conjunction with one another.

If this enhancement will not be used often, can it be worked around with a few lines of script?

Working around this is very clunky, requiring keeping a reference to the tween around, signalling whenever Engine.time_scale is updated, have the signal trigger an update function that will re-normalize the tween speed, and then clean up once the tween is finished or it won't be automatically freed. Very much goes against "set and forget" usage of tweens.

Is there a reason why this should be core and not an add-on in the asset library?

Tweens are core

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants