dotween
dotween copied to clipboard
Append Callback Between two Appends issue
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
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));`
my workaround to this issue was creating a getter for that variable, it will then get the value again when it is called.