dotween icon indicating copy to clipboard operation
dotween copied to clipboard

Append Callback Between two Appends issue

Open R0tmayer opened this issue 2 years ago • 2 comments

Hi there!

I want to change variable value after first Append is done and before second Append is started

Here is my code

        sign = 0;

        DOTween.Sequence()
            .Append(transform.DORotate(new Vector3(0, yAngle, 0), duration))
            .AppendCallback(() =>
            {
                var sign = Random.value > 0.5f ? -1 : 1;
            })
            .Append(transform.DOLocalRotate(new Vector3(0, randomAngle * sign, 0), randomDuration)
                .SetRelative(true));

But the problem is that when the second Append starts, the value of sign = 0, but the sign should be 1 or -1

R0tmayer avatar May 27 '22 12:05 R0tmayer

I'm running into something similar. The callback is working as intended but the new values are not being implemented. My best guess so far is that the tweening targets are being cached when the sequence starts, and aren't updated if the variables change.

    `Sequence rockSequence = DOTween.Sequence().SetLoops(totalCycles)

    rockSequence
                .Append(transform.DOLocalRotate(nextAng, time).SetEase(Ease.OutQuad))
                .AppendCallback(() => multiplier = rockSequence.CompletedLoops() == totalCycles - 2 ? -1.75f : -2f)
                .AppendCallback(() => nextAng += multiplier * offset)
                .Append(transform.DOLocalRotate(nextAng, 2 * time).SetEase(Ease.InOutQuad));`

JLDooley avatar Jun 02 '22 14:06 JLDooley

my workaround to this issue was creating a getter for that variable, it will then get the value again when it is called.

fakegood avatar Nov 11 '22 03:11 fakegood