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

Using SetDelay() in Godot 4 Tweeners makes them start from the value at the start of the delay rather than at the start of the interpolation #80388

Closed
jamesdkay opened this issue Aug 7, 2023 · 1 comment · Fixed by #80702

Comments

@jamesdkay
Copy link

Godot version

v4.1.stable.mono.official [9704596]

System information

Godot v4.1.stable.mono - Windows 10.0.19045 - Vulkan (Forward+) - dedicated NVIDIA GeForce GTX 1660 Ti (NVIDIA; 31.0.15.1640) - AMD Ryzen 7 4800H with Radeon Graphics (16 Threads)

Issue description

When you use SetDelay() with a Tweener the initial value that gets interpolated is the value at the start of the delay, rather than the value at the start of the tweening. If the Tween has been set to run in parallel using SetParallel(true) then this essentially has the same effect as if all the Tweeners were created with FromCurrent(). If the Tween is not set to run in parallel then the Tweeners use the initial value from the end of the last tween that run (ie before the delay) rather than the value when they actually start (ie. after the delay).

I would expect the same behavior from running two tweens in series and running two tweens in parallel where one has a delay set that's equal to the duration of the other one. The documentation isn't 100% clear on whether the intended behavior is to tween from the start of the tweening or from the start of the delay, but this definitely feels like the less natural way for this to work, and it makes a number of things rather more difficult.

An example of where this becomes very important is in a turn based game where a move triggers a series of events where various objects are tweened to a series of new positions (eg. slide, then fall). You could use a different tween to move each object (on non-parallel mode), but then if the turn is interrupted (eg. by an undo command during the turn) then you need to keep track of all the running tweens and stop them one-by-one. Another wat to make this work currently would be to keep track of the previous position of every object being moved and manually feed in that using From(), but this is also a lot of extra overhead.

Steps to reproduce

Run minimal reproduction project. Left click anywhere and the white square will be tweened to a new position, then a 1 second delay, then tweened back to its original position. Now try doing this again but right-click during the delay and the square will be moved right by 100 pixels. When the tween starts again after the delay it starts from the position when the delay started rather than its new position at the end of the delay.

Minimal reproduction project

tweener test.zip

@KoBeWi
Copy link
Member

KoBeWi commented Aug 8, 2023

Delay is part of the animation, so this is kind of expected behavior.
I wonder if it's better to change it or add an optional flag to set_delay().
EDIT: On a second though, it makes more sense to make it default.

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

Successfully merging a pull request may close this issue.

3 participants