-
-
Notifications
You must be signed in to change notification settings - Fork 21.7k
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
Discourage reusing Tweens #74258
Discourage reusing Tweens #74258
Conversation
A pointer for anyone else looking for more context re: Update: Additionally, the related code has diverged between v4.0 & v3.x backport: godot/scene/animation/tween.cpp Lines 156 to 192 in 31eccb5
godot/scene/animation/scene_tree_tween.cpp Lines 128 to 169 in e90ac4b
|
eda6a14
to
1944a6e
Compare
Ok I reworked the PR. Instead of saying "this is somewhat supported, but don't do it", I removed all documentation notes that imply reusing (pretending it's not supported at all) and only left a comment that it results in undefined behavior. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just saw some english problems
[b]Note:[/b] All [Tween]s will automatically start by default. To prevent a [Tween] from autostarting, you can call [method stop] immediately after it is created. | ||
[b]Note:[/b] [Tween]s are processing after all of nodes in the current frame, i.e. after [method Node._process] or [method Node._physics_process] (depending on [enum TweenProcessMode]). | ||
[b]Note:[/b] Tweens are not designed to be re-used and trying to do so results in an undefined behavior. Create a new Tween for each animation and every time you replay an animation from start. Also Tweens start immediately, so only create a Tween when you want to start animating. | ||
[b]Note:[/b] Tweens are processing after all of nodes in the current frame, i.e. after [method Node._process] or [method Node._physics_process] (depending on [enum TweenProcessMode]). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[b]Note:[/b] Tweens are processing after all of nodes in the current frame, i.e. after [method Node._process] or [method Node._physics_process] (depending on [enum TweenProcessMode]). | |
[b]Note:[/b] Tweens are processed after all of the nodes in the current frame, i.e. after [method Node._process] or [method Node._physics_process] (depending on [enum TweenProcessMode]). |
1944a6e
to
33c57f4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall, this version seems good to me.
33c57f4
to
9785b23
Compare
Thanks! |
What are best practices for persistent Tweens? https://godotengine.org/qa/148332/best-practices-for-creating-a-persistent-tween-in-godot-4 I'm kinda stuck because if we are supposed to use AnimationPlayer for this, not sure how to dynamically add Animations at runtime either: https://godotengine.org/qa/148336/how-can-i-add-animations-to-animationplayer-by-gdscript |
The answer is in the docs, although probably not obvious for this particular question: var tween
func animate():
if tween:
tween.kill() # Abort the previous animation.
tween = create_tween() Create the Tween inside |
Cherry-picked for 4.0.1. |
Closes #74245
Hopefully this will discourage people from even thinking about this 🙄