Demigiant / dotween

A Unity C# animation engine. HOTween v2
http://dotween.demigiant.com
Other
2.34k stars 351 forks source link

Backwards-playing tweens cannot loop infinitely #628

Closed caroparo closed 1 year ago

caroparo commented 1 year ago

In TweenManager.cs, line 549 handles isBackwards update with : while (toPosition < 0 && toCompletedLoops > -1) { It is different from line 560 for !isBackwards Update which covers the infinite loops case (t.loops == -1): while (toPosition >= t.duration && (t.loops == -1 || toCompletedLoops < t.loops)) { It seems to make Flip() on infinitely looping tweens impossible; I've tested with: while (toPosition < 0 && (t.loops == -1 || toCompletedLoops > -1)) { and it seems to have resolved the issue.

I don't quite understand what the comment in the isBackwards part means though, so I'm not sure what to do with that extra toPosition handling snippet. I had removed it and it didn't break my tweens. // Result is equivalent to a rewind, so set values according to it

Demigiant commented 1 year ago

Ahoy!

Indeed backwards tweens were never meant to be played infinitely, because conceptually an infinite tween is infinite only in its ending position while it always has a starting one. A trick in this case is to just create a tween with a very high number of loops, complete it (paying attention not to auto-kill it by completion), then play it backwards.