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

Make tweens process before nodes (to fix sync issues) #11837

Open
djrain opened this issue Feb 24, 2025 · 3 comments
Open

Make tweens process before nodes (to fix sync issues) #11837

djrain opened this issue Feb 24, 2025 · 3 comments

Comments

@djrain
Copy link

djrain commented Feb 24, 2025

Describe the project you are working on

A word game with particle effects

Describe the problem or limitation you are having in your project

Since tweens are processed after all nodes, this means I cannot access, for example, the updated position of a tweened node before rendering the frame. As a result any effects using the tweened position in _process() will appear a frame delayed, which is unacceptable in many cases and undesirable at best.

In my case, I have made a custom particle system that I wish to place as a child of the scene that gets moved with tweens, but it needs to emit in global coordinates (same as one often does with CPUParticles). However due to the tween processing late, I can't obtain the updated value to position the particles correctly, and this leads to visual glitches.

Another real example is this person who had the same problem making a grappling hook: https://www.reddit.com/r/godot/comments/1d3vcwj/processing_a_tween_after_process/

Here's a simple video demonstration: in _process() I just set the position of the Godot logo to match that of the white square. On top we move the square with a Tween (causing obvious, unavoidable desync) and on the bottom using AnimationPlayer with adjusted process priority (works as expected).

Screen.Recording.2025-02-23.at.5.54.27.PM.mov

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

Simply make tweens process before all nodes, instead of after. Then in _process() users can expect all values to be up to date for rendering, and there won't be any sync issues.

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

N/A

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

The only workaround is to not use tweens, which is hardly a solution.

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

It's core behavior

@KoBeWi
Copy link
Member

KoBeWi commented Feb 24, 2025

You can make Tweens process in physics frame, which could be a workaround in this case.

@Meorge
Copy link

Meorge commented Feb 24, 2025

Would changing the default behavior from "process after all nodes" to "process before all nodes" potentially be a breaking change for other users' projects? I feel like "process before all nodes" could maybe be a boolean setting to toggle, which defaults to false so that the current behavior is maintained by default.

@djrain
Copy link
Author

djrain commented Feb 24, 2025

You can make Tweens process in physics frame, which could be a workaround in this case.

Thank you for the suggestion! It's definitely not ideal, but you're right this can work in some cases. I guess the downsides are: it's unintuitive, fragile, doesn't work at all if you need your custom logic also in physics frame, and forces one to rely on physics interpolation

Would changing the default behavior from "process after all nodes" to "process before all nodes" potentially be a breaking change for other users' projects?

Potentially, though it seems like it would be very rare? I can't think of a likely scenario that would break

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

3 participants