@TheRunningStef said:
I don't know what's wrong because I tried putting add_child(Tween.new()) before the animation code, but it still doesnt work, suggesting that it's not just renamed or deleted the Tween node.
add_child(Tween.new())
will instance/create a new node, which shouldn't be necessary if you already have a Tween
node in the scene.
The newly instanced Tween
node will have an auto generated name, something like Node#5021
, so you'll likely want to keep a reference to it if you want to use it elsewhere in the script. If you want to create the Tween node from code, then you'll probably want to instance/create the tween node using code like this (untested):
var tween_node
func _ready():
# Spawn a new Tween node
tween_node = Tween.new()
tween_node.name = "Instanced_Tween"
add_child(tween_node)
func _process(delta):
if (tween_node.is_active() == false):
tween_node.interpolate_property(self, "position", Vector2(0, 0), Vector2(10, 10), 4, Tween.TRANS_LINEAR, Tween.EASE_IN_OUT)
I'm not sure if that is causing the issue, but it might be something to look into.
That said, if you already have a Tween node in the scene and you can access said Tween node in _ready
using get_node
, then the issue might be something else is overriding the variable and/or getting in the way when you try to retrieve the Tween node.
(My apologizes in advance for any mistakes, I was writing this in a bit of a hurry)