+1 vote

I currently am creating AudioStreamPlayer nodes from code when a button is pressed. When that button is pressed again, the audio is meant to fade out using a Tween also generated from code. What I don't understand is how to have the Tween node delete itself when the Tween is over.

When the Tween node is created, the following code is used to connect the "tweencompleted" signal, but clearly I am not using "queuefree" properly, or something else.

WeatherTween.connect("tween_completed", WeatherTween, "queue_free")

If I am understanding this correctly, this should connect the WeatherTween's "tween_completed" signal to itself, such that the signal triggers the node to delete itself at the next frame.

asked May 12 in Engine by fader (46 points)

1 Answer

0 votes
Best answer

You should see an error in the Debugger once the tween finishes:

emit_signal: Error calling method from signal 'tween_completed': 'Tween::queue_free': Method expected 0 arguments, but called with 2..

Use "tweenallcompleted" instead, it does not expect any arguments:

WeatherTween.connect("tween_all_completed", WeatherTween, "queue_free")
answered May 12 by njamster (8,992 points)
selected May 12 by fader

Thanks. That fixed it.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.