Skip to content

Conversation

@Kaleb-Reid
Copy link
Contributor

@Kaleb-Reid Kaleb-Reid commented Oct 27, 2025

The issue I have with this error is that I believe there is one valid use case for instantiating a tween without attaching it to a tree, which is during initialization of another object which has tween properties. Otherwise I either need to check that tween != null every time I need to do an operation on the tween to avoid race conditions, or create a tween attached to the tree for no reason and then immediately kill it so I don't get a different error for creating an empty tween. This is pointless if I'm never going to set the property to null.

An error is still printed if you try to append a tweener to a tween created with Tween.new() which says that the tween could have been created outside the scene tree. I could make that error more specific if the tween is created using Tween.new() if necessary.

@Kaleb-Reid Kaleb-Reid requested a review from a team as a code owner October 27, 2025 05:55
@Chaosus Chaosus added this to the 4.6 milestone Oct 27, 2025
@Meorge
Copy link
Contributor

Meorge commented Oct 28, 2025

This may also make using tween_subtween() more efficient. Currently, even if you know you're going to be making a tween as a subtween, you still have to initially add it to the tree with create_tween(), and then the tween_subtween() call later removes it.

@Kaleb-Reid
Copy link
Contributor Author

Kaleb-Reid commented Oct 28, 2025

@Meorge with this pr it still creates an invalid Tween aka it cannot have Tweeners appended. It's in the same state as a regular Tween which has finished tweening and the tree cleans it up so that is_valid() returns false.

Although I do think that it would be nice if tweens were more re-usable and there essentially weren't invalid tweens at all.

@Meorge
Copy link
Contributor

Meorge commented Oct 28, 2025

Ah ok, thank you for the correction!

In that case I might be a little worried about allowing the use of the Tween.new() constructor directly, as (at least to me) it implies it's ready to have tweeners added to it, similar to the result of create_tween().

@Kaleb-Reid
Copy link
Contributor Author

@Meorge My problem with that is if you try to append tweeners it will give you an error anyways saying that the tween may have been created outside of the scene tree and the docs also clearly state that using Tween.new() creates an invalid tween.

Additionally it would be trivial for me to make it directly say it was created with Tween.new() upon trying to append a tweener if it needs to be even more clear to the user.

So to actively prevent the user from initializing a variable with Tween.new() by printing an error which has no side effect is a bit ridiculous in my opinion.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants