godot icon indicating copy to clipboard operation
godot copied to clipboard

Unexpected set_parallel behavior in SceneTreeTween

Open firebelley opened this issue 3 years ago • 2 comments

Godot version

3.5.1.stable.mono

System information

Windows 11

Issue description

The set_parallel function of SceneTreeTween explicitly states that "Tweeners appended after this method will by default run simultaneously, as opposed to sequentially."

However, this is not the case. A tween defined before the call to set_parallel appears not to run at all. Or perhaps the tween defined after set_parallel is being run prematurely thus overriding it.

# Root node is a ColorRect
var tween = create_tween()
tween.tween_property(self, "color", Color.black, 1)
tween.tween_property(self, "color", Color.white, 1)
tween.set_parallel()
tween.tween_property(self, "color", Color.red, 1)

In the above snippet, I expect the following to happen:

  1. Tween the ColorRect to black over 1 second.
  2. Tween the ColorRect to white over 1 second.
  3. Enable parallel execution
  4. Tween the ColorRect to red over 1 second.

However, the observed behavior is instead as follows:

  1. The ColorRect is tweened to black over 1 second.
  2. The ColorRect is tweened to red over 1 second.

In the observed behavior, the transition back to white never happens. The tween goes immediately from black to red, despite the fact that a tween to white is specified before set_parallel is called.

Steps to reproduce

See issue description or minimal reproduction project.

Minimal reproduction project

SceneTreeTween Issue Example.zip

firebelley avatar Nov 27 '22 19:11 firebelley

set_parallel() has the same immediate effect as parallel(), i.e. the next Tweener will run in parallel to the previously defined one. In your case white and red animations happen at the same time and red is overwriting the color, because it's animated later.

Maybe the description needs some clarification.

KoBeWi avatar Nov 27 '22 21:11 KoBeWi

Yeah that doesn't make sense given the description. The description of set_parallel only mentions tweens set after the call. Arguably it should not have any immediate effect. Otherwise every tween defined immediately prior to the call will be parallelized which, I would guess, would be undesired in almost every case. At the very least it's not intuitive.

firebelley avatar Nov 27 '22 21:11 firebelley