0 votes

I need a certain tween to complete immediately when there is a mouse click. I haven't found of a specific method on the Tween to achieve this, so I was wondering if it was possible at all.

I know that I could fake it by stopping the tween and assigning the final value to the object, but i was wondering if there was a more convenient way of doing so directly from the tween since it would be much more convenient.

in Engine by (14 points)

2 Answers

+2 votes

To be honest, what you were contemplating is not that complicated. In fact, you can just set up a static function once in a new GDScript and load it as a resource, whenever you need to reuse it.

# new GDScript
# don't extend anything

static func premature_tween_stop(tween):
    tween.stop()
    finalize_tween()

In another script:

var Utility = preload("res://Utility.gd")

var tween = Tween.new()
# start tween
Utility.premature_tween_stop(tween)
by (840 points)
+1 vote

I was able to break out of a yielded tween using tween.emitsignal("tweencompleted") on detection of user input.

by (69 points)
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.
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 webmaster@godotengine.org with your username.