Skip to content

Alert about the risks of using SceneTree.create_tween() instead of Node.create_tween() #7796

Closed
godotengine/godot
#81087
@fguillen

Description

Your Godot version:
4.1.1

Issue description:
When create a tween by SceneTree.create_tween() the Tween will be created outside the Node. So when the Node is freed the Tween remains alive. As when creating a Tween the more usual is to manipulate the Node when it is created there are many chances that using SceneTree.create_tween() we will end up in an error situation:

Screenshot 2023-08-10 at 22 38 06

I suggest adding a warning note:

A Tween can be created by using either SceneTree.create_tween or Node.create_tween. Tweens created manually (i.e. by using Tween.new()) are invalid and can't be used for tweening values.

Add:

Beware that when creating the Tween by using SceneTree.create_tween the Tween will be detached from the actual Node and it won't be killed when the Node is freed. Maybe you will prefer to use Node.create_tween if you want the Tween to be automatically killed when the Node is freed.

Or something like this. If this would be there it would have saved me so many headaches :)

URL to the documentation page (if already existing):
https://docs.godotengine.org/en/stable/classes/class_tween.html#description

Activity

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

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions