Can you tell my why you use create_tween() here, and not for example the get_tree().create_tween()?
Also, is there a need to clean op tweens? (call kill()) Or are they special, and clean up after themselves?
Can you tell my why you use create_tween() here, and not for example the get_tree().create_tween()?
Also, is there a need to clean op tweens? (call kill()) Or are they special, and clean up after themselves?
Hi mveerman,
There is very little in the documents to explain the difference but i think its because we are manipulating the a property of the object that the script is attached to rather than the object itself.
Hopefully this explains the difference but i can check with Bramwell if this is the case.
Hi,
heres a little more info that i found.
tweens as of godot 4 are no longer nodes like they used to need.
instead, they are now objects created via code and are what as classed as refCounted and managed by the scenetree itself.
as they are refCounted, which means, once there is no longer a reference held to them they are automatically deleted the following frame. much like the scope of a variable in that respect.
what it looks like is there are a couple of ways to create the tweens as you mentioned.
as there is the SceneTree.create_tween as in get_tree().create_tween()
and when we just use the create_tween() on a node script, as in node.create_tween.
they are both doing pretty much the same thing at the end of the day, as they are all managed by the scenetree itself,
calling create_tween() within a nodes script, binds that tween object to that node its on.
which is the same as would be calling get_tree().create_tween().bind(mynodename).
but create_tween() on a node is nicer to read.
they can also be created at the root of the tree as well and you can $ reference a node in your game tree to manipulate.
the docs have a good list of a few examples for further reading.
Tween (4.1 docs) — Godot Engine (stable) documentation in English
hope that helps further
Darren
This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.