summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkobewi <kobewi4e@gmail.com>2023-12-02 20:20:50 +0100
committerkobewi <kobewi4e@gmail.com>2023-12-02 20:20:50 +0100
commit20aecefd9bdde8c806645432e3989f11ddc6e90d (patch)
tree84a5d0c640771549f3e5a3eb79bd2d82f51dd11b
parentd76c1d0e516fedc535a2e394ab780cac79203477 (diff)
downloadredot-engine-20aecefd9bdde8c806645432e3989f11ddc6e90d.tar.gz
Fix Tween loop initial value
-rw-r--r--scene/animation/tween.cpp13
-rw-r--r--scene/animation/tween.h1
2 files changed, 9 insertions, 5 deletions
diff --git a/scene/animation/tween.cpp b/scene/animation/tween.cpp
index d6a6af3f08..8193bbf3f1 100644
--- a/scene/animation/tween.cpp
+++ b/scene/animation/tween.cpp
@@ -549,9 +549,12 @@ void PropertyTweener::start() {
return;
}
- if (do_continue && Math::is_zero_approx(delay)) {
- initial_val = target_instance->get_indexed(property);
- do_continue = false;
+ if (do_continue) {
+ if (Math::is_zero_approx(delay)) {
+ initial_val = target_instance->get_indexed(property);
+ } else {
+ do_continue_delayed = true;
+ }
}
if (relative) {
@@ -576,10 +579,10 @@ bool PropertyTweener::step(double &r_delta) {
if (elapsed_time < delay) {
r_delta = 0;
return true;
- } else if (do_continue && !Math::is_zero_approx(delay)) {
+ } else if (do_continue_delayed && !Math::is_zero_approx(delay)) {
initial_val = target_instance->get_indexed(property);
delta_val = Animation::subtract_variant(final_val, initial_val);
- do_continue = false;
+ do_continue_delayed = false;
}
double time = MIN(elapsed_time - delay, duration);
diff --git a/scene/animation/tween.h b/scene/animation/tween.h
index 10c7a272ef..053b4fac46 100644
--- a/scene/animation/tween.h
+++ b/scene/animation/tween.h
@@ -225,6 +225,7 @@ private:
double delay = 0;
bool do_continue = true;
+ bool do_continue_delayed = false;
bool relative = false;
};