Tween: how to stop current animation and force to continue next current animation?

Godot Version

v4.3.stable.official [77dcf97d8]

Question

For example, I have the following code:

var tween = create_tween()

tween.set_loops()
tween.set_parallel(false)

# Animation #1 -> Move to destination:
var protween.tween_property(self, "position:x", 50.0, 10.0)
tween.tween_interval(2.0)

# Animation #2 -> Returns to the initial position
tween.tween_property(self, "position:x", 0.0, 10.0)
tween.tween_interval(2.0)

Assuming the Tween is running “Animation #2” but has not finished and I want to stop that animation and force it to move on to “Animation #1”, is this possible to do?

I would separate the tween into 2 different objects, called destination_tween and origin_tween. Then you can call start and stop on them individually.

2 Likes