Demigiant / dotween

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

OnComplete called even with DOTween.Kill(..., complete : false) #622

Closed builder-main closed 1 year ago

builder-main commented 1 year ago

I'm on dotween latest, 1.2.705 I think there is a bug there, something that is not documented or that I missed. OnComplete callback is always called, even if I kill the tween early, adding/removing the complete parameter do not change anything. I also tried to check what was happening by retrieving the tween from DOTween.TweensById(tweenId) before killing it to see its state, but it returns NULL, and DOTween.PlayingTweens do not retrieve the tween being played. (And there is not doubt it's tweening).

So I'm a bit out of clue. I'll dive in the doc meanwhile.

                 DOTween.Kill(tweenId, complete:false);

                Tween tween = default;
                tween = tmpTarget.transform.DOMove(target.position, tweenSettings.Duration)
                    .SetSpeedBased(tweenSettings.IsSpeedBased)
                    .SetEase(tweenSettings.EaseType)
                    .SetUpdate(tweenSettings.UpdateType, isIndependentUpdate: tweenSettings.IsUnscaledTime)
                    .SetId(tweenId)
                    .SetAutoKill(true)
                    .OnComplete(() =>
                    {
                        setTarget(target);
                        Debug.Log($"[DEV]Set Target end tween {target.name}, tween was completed {tween.IsComplete()}/{tween.intId}");
                    })
                    .OnKill(() => destroyFunc(tmpTarget));
builder-main commented 1 year ago

Would reusing the same Id be a problem ? I'm not using a target, as the tween stays the same but the target does not. The return value of Kill is 1 when I'm interupting the tween and 0 otherwise, as expected.

builder-main commented 1 year ago

It is definitelly related to the way the tween is handled with the Ids, as I just now create and kill tweens directly with the returned instance and it works smoothly. As wanted, OnComplete is not called on the kill call. (removed call to .SetId(tweenId) and just kill the tween Reference that is returned tween.Kill() instead of DOTween.Kill(tweenId, complete:false);)

builder-main commented 1 year ago

Okay, my fault, A KillAll was hanging out in the code and breaking things in parallel.