Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tween_interval() works strangely with set_parallel() #74608

Open
zjf0123 opened this issue Mar 8, 2023 · 5 comments
Open

tween_interval() works strangely with set_parallel() #74608

zjf0123 opened this issue Mar 8, 2023 · 5 comments

Comments

@zjf0123
Copy link

zjf0123 commented Mar 8, 2023

Godot version

4.0.stable

System information

Win10

Issue description

extends ColorRect

func _ready():
	var tween = create_tween()
	tween.tween_property(self,"scale",Vector2(2,2),1)
	tween.tween_interval(2)
	tween.set_parallel()
	tween.tween_property(self,"position",position +Vector2(50,50),0.3)
	tween.tween_property(self,"modulate",Color.RED,0.3)

The sequence of execution of this code in my imagination is:

ColoRect first magnifies the scale to twice in 1 second, and then after a delay of 2 seconds, it simultaneously changes its position and modulate to the specified value in 0.3 seconds.

But the fact is that after taking a second to adjust its scale, it skipped tweet.tween_ Interval (2) sets the 2-second delay. Instead, it directly start modifying position and modulate .

It looks like set_parallel() will execute the previous IntervalTweener at the same time.

But the description in the document is as follows:

"the Tweeners appended after this method will by default run simultaneously, as opposed to sequentially."

I don't know whether my understanding is wrong or there is a bug here.

Steps to reproduce

You use the code in the above question to reproduce.

Minimal reproduction project

N/A

@Chaosus Chaosus added this to the 4.x milestone Mar 8, 2023
@Chaosus
Copy link
Member

Chaosus commented Mar 8, 2023

cc @KoBeWi

@timothyqiu
Copy link
Member

I believe this is intended behavior. The documentation could be improved.

The tricky part is how "parallel" works, it's relative to the previous tweener instead of the next one.

tween.tween_property(self,"scale",Vector2(2,2),1)  # starts after the previous ones finish
tween.tween_interval(2)  # starts after the previous ones finish
tween.set_parallel()
tween.tween_property(self,"position",position +Vector2(50,50),0.3)  # starts together with the previous one
tween.tween_property(self,"modulate",Color.RED,0.3)  # starts together with the previous one

So conceptually:

[
    [ PropertyTweener(scale) ],
    [ IntervalTweener(2), PropertyTweener(position), PropertyTweener(modulate) ],
]

@zjf0123
Copy link
Author

zjf0123 commented Mar 8, 2023

Thank you. You explained it very clearly!

@zjf0123 zjf0123 closed this as completed Mar 8, 2023
@Chaosus Chaosus removed this from the 4.x milestone Mar 8, 2023
@romlok
Copy link
Contributor

romlok commented Jul 21, 2023

Perhaps this should be reopened? At the very least, the documentation seems to still be misleading on this matter.

I just spent a good deal of time trying to work out why my tweens weren't happening in the order I expected. 😖

I think it would be a lot more intuitive for set_parallel to work as both myself and the OP expected. Since we generally read code from top to bottom, one could far more quickly and easily comprehend a sequence of tweens if the set_parallel function announced the beginning of the parallelism. Right now, as one is reading a program, one has to rewind to reinterpret the previous tween operation when one hits a set_parallel 😕

tween.tween_property(self, "scale", Vector2.ONE * 2, 1.0)
tween.tween_property(self, "position", Vector2.ZERO, 1.0)
tween.begin_parallel() # Everything after here is parallel
tween.tween_property(self, "position", Vector2(100, 100), 1.0)
tween.tween_property(self, "scale", Vector2.ONE, 1.0)

# vs

tween.tween_property(self, "scale", Vector2.ONE * 2, 1.0)
tween.tween_property(self, "position", Vector2.ZERO, 1.0) # Everything after here is parallel
tween.tween_property(self, "position", Vector2(100, 100), 1.0)
tween.set_parallel() # But you don't know that until you get here
tween.tween_property(self, "scale", Vector2.ONE, 1.0)

@Lippanon
Copy link

To prevent compatibility breakage, perhaps 2 new methods could be added: begin_parallelism and end_parallelism (or similar names).
A workaround for many cases is to add a dummy tween_interval(0.0) before a parallel call, for example in OP's example it would be added after tween.tween_interval(2), then it should run as expected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants