The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates.

godotengine.org | Twitter

+2 votes

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.
enter image description here
And the callback isn't called.

in Engine by (29 points)

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.

1 Answer

+3 votes
Best answer

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.

by (9,800 points)
selected by

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

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

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.