When i try to access tween property, the game gives the following error “Cannot call method ‘from’ on a null value.”
Here’s the code "
#Destruir la carta
container.material=DISSOLVE
if tween_destroy and tween_destroy.is_running():
tween_destroy.kill()
tween_destroy = create_tween().set_ease(Tween.EASE_IN_OUT).set_trans(Tween.TRANS_CUBIC)
tween_destroy.tween_property(material, “shader_parameter/dissolve_value”, 0.0, 1.0).from(1.0) #HERE IT’S THE PROBLEM
queue_free()"
It should be
if tween_destroy:
tween_destroy.kill()
tween_destroy = create_tween()
.....
You don’t need to check if it is running. If the tween_destroy instance has been freed, checking is_running will give you an error.
even without the comprobation in the line tween_destroy.tween_property(material, “shader_parameter/dissolve_value”, 0.0, 1.0).from(1.0) it tells you that the tween its null
remember to
.bind_node(self)
at very least when you create a tween
so it look like:
tween_destroy = create_tween().bind_node(self).set_ease(Tween.EASE_IN_OUT).set_trans(Tween.TRANS_CUBIC)
create_tween
binds to the node calling it by default.
Creates a new Tween and binds it to this node. Fails if the node is not inside the tree.
This is the equivalent of doing:
get_tree().create_tween().bind_node(self)
Where is material
defined? Did you want to tween on container.material
?