Why is tween completed being called multiple times?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By imekon

I’ve setup a tween with:

tween.interpolate_method(self, "droppingCallback", 0.0, 1.0, 1.0, Tween.TRANS_QUAD, Tween.EASE_IN)
tween.start()

What happens is when the tween reaches the end, I see the completion callback being called multiple times. How do I know which is the last one? I used a flag initially but I need to restart the tween - I suppose I could restart the tween within the callback?

:bust_in_silhouette: Reply From: kidscancode

Are you sure you’re not calling the tween on more than one instance, or interpolating more than one property? The completed callback includes two parameters: the object and the key. To see what is actually completing try this and see what prints:

func _on_tween_completed(object, key):
    printt(object, key)

If I add print(object, key), this is what I get:

[Node2D:960]:droppingCallback
[Node2D:960]:droppingCallback
[Node2D:960]:droppingCallback
[Node2D:960]:droppingCallback
[Node2D:960]:droppingCallback
[Node2D:960]:droppingCallback
[Node2D:960]:droppingCallback
[Node2D:960]:droppingCallback
[Node2D:960]:droppingCallback
[Node2D:960]:droppingCallback
[Node2D:960]:droppingCallback
[Node2D:960]:droppingCallback
[Node2D:960]:droppingCallback
[Node2D:960]:droppingCallback 
[Node2D:960]:droppingCallback
[Node2D:960]:droppingCallback
[Node2D:960]:droppingCallback 
[Node2D:960]:droppingCallback
[Node2D:960]:droppingCallback
[Node2D:960]:droppingCallback 
[Node2D:960]:droppingCallback
[Node2D:960]:droppingCallback
[Node2D:960]:droppingCallback

imekon | 2018-04-02 21:29

Ah…

I’m calling start() multiple times!

imekon | 2018-04-02 21:36