File tree Expand file tree Collapse file tree 2 files changed +8
-2
lines changed Expand file tree Collapse file tree 2 files changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -303,6 +303,8 @@ Ref<Tween> Tween::chain() {
303303}
304304
305305bool Tween::custom_step (double p_delta) {
306+ ERR_FAIL_COND_V_MSG (in_step, true , " Can't call custom_step() during another Tween step." );
307+
306308 bool r = running;
307309 running = true ;
308310 bool ret = step (p_delta);
@@ -329,6 +331,7 @@ bool Tween::step(double p_delta) {
329331 if (!running) {
330332 return true ;
331333 }
334+ in_step = true ;
332335
333336 if (!started) {
334337 if (tweeners.is_empty ()) {
@@ -339,6 +342,7 @@ bool Tween::step(double p_delta) {
339342 } else {
340343 tween_id = to_string ();
341344 }
345+ in_step = false ;
342346 ERR_FAIL_V_MSG (false , tween_id + " : started with no Tweeners." );
343347 }
344348 current_step = 0 ;
@@ -357,7 +361,7 @@ bool Tween::step(double p_delta) {
357361 bool potential_infinite = false ;
358362#endif
359363
360- while (rem_delta > 0 && running ) {
364+ while (running && rem_delta > 0 ) {
361365 double step_delta = rem_delta;
362366 step_active = false ;
363367
@@ -392,6 +396,7 @@ bool Tween::step(double p_delta) {
392396 potential_infinite = true ;
393397 } else {
394398 // Looped twice without using any time, this is 100% certain infinite loop.
399+ in_step = false ;
395400 ERR_FAIL_V_MSG (false , " Infinite loop detected. Check set_loops() description for more info." );
396401 }
397402 }
@@ -402,7 +407,7 @@ bool Tween::step(double p_delta) {
402407 }
403408 }
404409 }
405-
410+ in_step = false ;
406411 return true ;
407412}
408413
Original file line number Diff line number Diff line change @@ -122,6 +122,7 @@ class Tween : public RefCounted {
122122 bool is_bound = false ;
123123 bool started = false ;
124124 bool running = true ;
125+ bool in_step = false ;
125126 bool dead = false ;
126127 bool valid = false ;
127128 bool default_parallel = false ;
You can’t perform that action at this time.
0 commit comments