How to make Tween.stop_all() correctly stop all animations

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

Trying to animate a PanelContainer with a Tween in and out of screen (in this example between 0 and 200 y position), where going away is slow (5 sec) and going in fast (1 sec).

For some reason calling tween stop_all does not interrupt a currently running animation, as seen here Imgur: The magic of the Internet. If the slow animation is interrupted it is resumed as soon as the fast animation is completed. Only after the slow animation is done can the quick animation complete and stay at the target position.

Scene structure and code (script of Node):


  • PanelContainer
    • Label
  • Tween
extends Node
onready var tween = get_node("Tween")
onready var node = get_node("PanelContainer")
onready var msg = get_node("PanelContainer/Label")

func _input(event):
	if event.is_action_pressed("ui_down"):
		msg.text = "down"
	elif event.is_action_pressed("ui_up"):
		msg.text = "up"

func go_in(duration=.5):
	tween.interpolate_property(node, "rect_position:y", node.rect_position.y, 200, duration, Tween.TRANS_LINEAR, Tween.EASE_OUT)

func go_away(duration=1.0):
	var rect_position_y = 0
	tween.interpolate_property(node, "rect_position:y", node.rect_position.y, rect_position_y, duration, Tween.TRANS_LINEAR, Tween.EASE_OUT)