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

Fix no tween repeat after stop and restart (Fix #39801) #46609

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion scene/animation/tween.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -869,8 +869,21 @@ void Tween::start() {
return;
}

pending_update++;
for (List<InterpolateData>::Element *E = interpolates.front(); E; E = E->next()) {
InterpolateData &data = E->get();
data.active = true;
}
pending_update--;

// We want to be activated
set_active(true);

// Don't resume from current position if stop_all() function has been used
if (was_stopped) {
seek(0);
}
was_stopped = false;
}

void Tween::reset(Object *p_object, StringName p_key) {
Expand Down Expand Up @@ -939,7 +952,7 @@ void Tween::stop(Object *p_object, StringName p_key) {
void Tween::stop_all() {
// We no longer need to be active since all tweens have been stopped
set_active(false);

was_stopped = true;
// For each interpolation...
pending_update++;
for (List<InterpolateData>::Element *E = interpolates.front(); E; E = E->next()) {
Expand Down
1 change: 1 addition & 0 deletions scene/animation/tween.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ class Tween : public Node {
float speed_scale = 1.0;
mutable int pending_update = 0;
int uid = 0;
bool was_stopped = false;

List<InterpolateData> interpolates;

Expand Down