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 a universal time_scale property to Node #2507

Closed
TheDuriel opened this issue Mar 25, 2021 · 18 comments
Closed

Add a universal time_scale property to Node #2507

TheDuriel opened this issue Mar 25, 2021 · 18 comments

Comments

@TheDuriel
Copy link

TheDuriel commented Mar 25, 2021

Describe the project you are working on

A game which involves slow motion effects or gameplay. General Godot engine projects.

Describe the problem or limitation you are having in your project

This proposal is mainly about the pull request linked below.

There are two 'problems' this feature is intended to solve:

Unification of time properties for Nodes under one property belonging to Node itself. For example animationplayers and streamplayers already incorporate their own time multipliers.

Selective slow motion effects. For example you could set a different timescale for the game world (without requiring the implementation of a custom main loop via propagate_call("_my_process_replacement"), and another value for the UI.) Or shift only specific enemies or objects while keeping the rest at its proper speed.

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

The feature adds a time_scale property to Node which multiplies delta locally. The property is also inherited.

Example: A time_scale of 0.5 would multiply Delta by that much. This is cumulative through the Scene. Meaning if a parent and a child have a time_scale of 0.5. The parent would function at 0.5, while the child would function at an effective 0.25. (The exact same way transforms are 'inherited'.)

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

Example implementation: godotengine/godot#29861

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

Currently selective time scaling requires implementation of a custom _process function via _propagate call in a root objects of the tree. The alternative is to provide a global value for your scale, and to remember to multiply delta in relevant nodes. However neither of these approaches allow you to affect the engine internal time scale for individual nodes or branches of the scene tree.

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

Modification of the Node class.

@Calinou Calinou changed the title Add universal TimeScale property to Node Add an universal time_scale property to Node Mar 25, 2021
@YuriSizov YuriSizov changed the title Add an universal time_scale property to Node Add a universal time_scale property to Node Mar 25, 2021
@aaronfranke

This comment has been minimized.

@TheDuriel

This comment has been minimized.

@Zireael07
Copy link

I imagine it would also help with things such as godotengine/godot#47326 (comment) (animation players/shaders/etc could be stopped by setting time_scale to 0?)

@aaronfranke
Copy link
Member

This was discussed on Godot's RocketChat. The consensus is that this change is not necessary, and therefore this proposal is not desired. You can scale time yourself in the script, and other nodes such as particles or animation already support time scaling.
For physics time scaling won't work anyway because the solver will break. So, closing.

@Zireael07
Copy link

How do I pause shaders then?

@TheDuriel
Copy link
Author

TheDuriel commented Aug 31, 2021 via email

@aaronfranke aaronfranke closed this as not planned Won't fix, can't repro, duplicate, stale Sep 18, 2022
@ettiSurreal
Copy link

This was discussed on Godot's RocketChat. The consensus is that this change is not necessary, and therefore this proposal is not desired. You can scale time yourself in the script, and other nodes such as particles or animation already support time scaling. For physics time scaling won't work anyway because the solver will break. So, closing.

I feel like the real usefulness of this comes from nodes inheriting the time scale of their parents, which i assume would greatly simplify changing local time of a large and unspecified amount of nodes with varying amounts of parents. For example parenting objects to an area that has a modified time scale as they enter it and unparenting as they leave, or slowing down everything but the player.
To make such system and effects through scripts you'd need to implement local time scale to every relevant script in the project, and make it work with many scenarios like an arbitrary parent structure. As a whole this seems like a nightmare to make.

Since i have seen PRs to add time scale to more nodes like timers, i do feel like making a generic node time scale property and moving the time scale of the nodes like particles to it would be some nice future proofing.

Also i assume by the physics solver breaking you meant objects of different time scale interacting. In that case the user could just be told that so they can avoid such situations. There are still use cases of this like local slow-mo areas where you logically won't have objects of different time scale interacting.

I really hope this feature will be reconsidered sometime.

@aaronfranke
Copy link
Member

@ettiSurreal I think that would be unlikely. In fact, I think it's more likely to go in the opposite direction. Godot's core types are quite big and complex compared to their equivalents in other engines and it's a big part of why Godot is less efficient. I would be interested in PRs that remove features from core types and leave the features to descendant types. Godot's Object is 408 bytes, while Unreal Engine's UObject is only 56 bytes.

@Zireael07
Copy link

@aaronfranke Removing features from core types sounds like a topic for a separate proposal - and it intrigues me why our Object is so large compared to UE's?

@ettiSurreal
Copy link

@ettiSurreal I think that would be unlikely. In fact, I think it's more likely to go in the opposite direction. Godot's core types are quite big and complex compared to their equivalents in other engines and it's a big part of why Godot is less efficient.

Interesting to hear, I figured in this specific case it's something most nodes and scripts would benefit from if it were added. And I'm guessing main reason for the size of the core types was avoiding code repetition or versatility?

@Calinou
Copy link
Member

Calinou commented Sep 25, 2023

What is the path, to re-open this proposal or bring it to consideration again?

There was a pull request adding exactly the feature you're requesting (for the Timer node), but it was rejected: godotengine/godot#34544

You should open a new proposal describing your needs around the Timer node, as this proposal was specifically requesting a time_scale property for any node that extends Node (including Timer).

In Godot, we prefer local solutions, so a time_scale property in Timer is more likely to be accepted than a time_scale property in Node. We try to keep Node and Object as lightweight as possible to reduce performance overhead and memory utilization.

@ettiSurreal
Copy link

ettiSurreal commented Sep 26, 2023

In Godot, we prefer local solutions, so a time_scale property in Timer is more likely to be accepted than a time_scale property in Node. We try to keep Node and Object as lightweight as possible to reduce performance overhead and memory utilization.

Might aswell throw in a potential idea that could fit into that, though I'm not sure how feasable/helpful it'd be: A dedicated node that controls the time scale of its children.

@TheDuriel
Copy link
Author

There is no good way to achieve a local solution.

Per Scene time scale, something that many games do enjoy to use, is not possible without a developer implementing custom time scale implementations for physics, timers, and animations. In many of these cases the solution can not be achieved without hacky workarounds.

Physics for KinematicBodies can be achieved by scaling the delta in your physics integration. This is not possible for RigidBodies.

Timers can not be scaled. And thus can not be used whatsoever.

AnimationPlayer supports time scaling, but when you use an animation tree it does not as far as I can tell.

@TheDuriel
Copy link
Author

That's nuts and not acceptable in the slightest.

@jbromberg
Copy link

Could a good potential solution here to have a unique time_scale property on each SceneTree? At least in my case, this would basically solve what I'm after.

@rpahut
Copy link

rpahut commented Apr 25, 2024

a time_scale property in Timer is more likely to be accepted

I feel like proposals shouldn't be subject to probability. Once a missing feature is identified, the only valid reason for rejection might be that the engine is not supposed to have the feature in the first place. So, should not engine allow for individual time scales? Why?

Besides, what good a local solution for a thing like time rate is? All nodes share process(delta), all nodes should have the way to control it. Surely one unified way is easier to implement and maintain that a bunch of different ones.

@rpahut
Copy link

rpahut commented Apr 25, 2024

For physics time scaling won't work anyway because the solver will break.

Why would it break?
Can't you make it in a way that it doesn't?

@ettiSurreal
Copy link

Another thing I wanna add, something i ran into recently.
In my project i have a part where everything goes slow-mo, and i used time_scale for it. However because of that i ran into an issue, since time_scale affects everything, it also slowed down the pause menu, and it would persist if the player would quit off the level. The only solution was to disable the pause menu and add a failsafe that resets the time_scale in my custom SceneLoader autoload. This is a short one-off thing in my project so it's not that big of a deal, but it might become an issue in a project that would rely on it.

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

No branches or pull requests

7 participants