0 votes

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?

asked Apr 2, 2018 in Engine by imekon (229 points)

1 Answer

+1 vote

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)
answered Apr 2, 2018 by kidscancode (17,168 points)

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

Ah...

I'm calling start() multiple times!

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.