Why is infinty tweening within a sequence not allowed? #102
-
I have written code where the transform appears (Scale = 1) and then keeps moving between 100f and 0f. var sequence = Tween.Scale(transform, startValue: 0f, endValue: 1f, duration: 0.4f)
.Chain(
Sequence.Create(-1)
.Chain(Tween.LocalPositionX(transform, endValue: 100f, duration: 1f))
.Chain(Tween.LocalPositionX(transform, endValue: 0f, duration: 5f))
);
// ~~~
sequence.Stop(); Executing this code will result in the error The behavior of this code is exactly as I envisioned. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi, thanks for the question! This was a design decision not to allow infinite tweens inside sequences. In your particular use case it looks reasonable, but there are many other corner cases when an infinite animation inside the sequence would not make sense and will break other things. For example, if infinite tweens were allowed inside sequences:
To sum up, all tweens and sequences in PrimeTween should have a defined duration. Infinite animations can only be achieved with As a workaround for your case, you can set some big value to the nested sequence with |
Beta Was this translation helpful? Give feedback.
Hi, thanks for the question!
This was a design decision not to allow infinite tweens inside sequences. In your particular use case it looks reasonable, but there are many other corner cases when an infinite animation inside the sequence would not make sense and will break other things. For example, if infinite tweens were allowed inside sequences:
sequence.progress/progressTotal/duration/durationTotal
.Sequence.Chain()
would not be allowed because the insertion point would be unknown (infinite).Sequence.Create(cycles: numCycles)
orsequence.SetRemainingCycles()
would not …