Connecting tween_complete signal

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Ilya
:warning: Old Version Published before Godot 3 was released.

Hi,

I was trying to create a simple pos interpolation func using tween, but can’t get a callback with tween_complete when it’s finished.

func climb():
    var anim = Tween.new()
    add_child(anim)
    # doesn't work!! -_-
    anim.connect("tween_complete", self, "timeout")
    anim.interpolate_property(self, "transform/pos", get_pos(), get_pos()+Vector2(10,10), 5, Tween.TRANS_LINEAR, Tween.EASE_IN_OUT)
    anim.start()

func timeout():
    print("timeout")

After the pos is changed I’m getting an error in debug window without any details.

And the callback isn’t called.

If you hover the error there’s a tooltip that might give some insight (it shows the C++ error). This is fixed for 2.1, which will show the C++ error if there’s no proper description.

vnen | 2016-06-28 16:47

:bust_in_silhouette: Reply From: volzhs

tween_complete( Object object, String key ) This signal is emitted when a tween ends.

This is what reference document says.
You need to make 2 parameter for tween_complete signal.

func timeout(obj, key):
    print("timeout : obj = ",obj,", key = ", key)

This will work.

Many thanks! I didn’t know callback must include the parameters.

Ilya | 2016-06-28 11:26

For anyone else reading: as of 2020 the signal name is tween_completed

bitbutter | 2020-11-15 09:31