How to kill current running DoTween sequence in Unity3d?

33,775

Solution 1

That's because you're trying to use the DoTween class itself. Rather, you should be using a reference to the sequence to kill it.

Code below

Sequence mySequence = DOTween.Sequence();

//Your code here  
mySequence.Append(transform.DoMove(Vector3.right, 1).SetLoops(2, LoopType.Yoyo))  
.Append(transform.DoMove(Vector3.up, 1).SetLoops(2, LoopType.Yoyo))  
.OnComplete(() => {  
    Debug.Log("Done");
});

mySequence.Kill(); //Kill the sequence.

Solution 2

In my case sequence.Kill() does not work, so I tried Dotween.Kill(object targetOrId), it worked, maybe you can have a try.

Share:
33,775
zszen
Author by

zszen

Updated on November 11, 2021

Comments

  • zszen
    zszen over 2 years

    DOTween.Kill api return number of actual tweens killed. but use this api can't kill transform's sequence tweens.

    DOTween.Kill (this); or DOTween.Kill (transform); or DOTween.Rewind api all can't kill it.