+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.

in Engine by (47 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")
by (10,582 points)
selected by

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 Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.