Complete a tween immediately

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

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.

:bust_in_silhouette: Reply From: Footurist

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):

In another script:

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

var tween =
# start tween
:bust_in_silhouette: Reply From: Jams

I was able to break out of a yielded tween using tween.emit_signal(“tween_completed”) on detection of user input.