Interpolation factor can be calculated incorrectly when cyclic tween is not started yet
Closed this issue · 4 comments
IAFahim commented
For this given code, it should have been:
Repeat 1...3
1. Sprite Turns Red → White (Rewind)
2. LocalTransform (0,0,0) → (0,1,0) (Rewind)
3. Sprite Turns Green → Light Green (Rewind)
public int cycles = 10;
public Collider2D anyCollider2D;
private Sequence _sequence;
public TweenSettings<Color> tweenSettingsWindUp;
public TweenSettings<Vector3> tweenSettingsPositionActive;
public TweenSettings<Color> tweenSettingsCooldown;
public SpriteRenderer cross;
private void OnEnable()
{
anyCollider2D.enabled = false;
if (_sequence.isAlive) _sequence.Complete();
_sequence = Sequence.Create(cycles)
.Chain(Tween.Color(cross, tweenSettingsWindUp))
.ChainCallback(() =>
{
anyCollider2D.enabled = true;
cross.color = Color.red;
})
.Chain(Tween.LocalPosition(cross.transform, tweenSettingsPositionActive))
.ChainCallback(() => { anyCollider2D.enabled = false; })
.Chain(Tween.Color(cross, tweenSettingsCooldown))
;
}
What happens:
Repeat 1...?
1. Sprite Turns Red → White (Rewind)
2. LocalTransform (0,0,0) → (0,1,0) (Rewind)
3. Sprite Turns Green → Light Green (Rewind)
?. OnComplete: LocalTransform (0,0,0) → (0,1,0)
Recording.2024-04-08.001752.mp4
KyryloKuzyk commented
Huge thanks for the detailed bug report!
I will probably not have any free time during the week and will look at the problem only the next weekend.
Can you please tell me what PrimeTween version you use?
IAFahim commented
Using version 1.1.14
KyryloKuzyk commented
I replicated the issue on my side and can confirm this is a bug. I already know the cause and will fix the problem soon.
KyryloKuzyk commented
I fixed this in version 1.1.16. Huge thanks for reporting the bug!
Can you please update to the latest version and tell me if the fix works for you?