Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to kill current running DoTween sequence in Unity3d?

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.

like image 221
zszen Avatar asked May 07 '26 19:05

zszen


2 Answers

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.
like image 159
Venkat at Axiom Studios Avatar answered May 09 '26 07:05

Venkat at Axiom Studios


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

like image 35
Jason Avatar answered May 09 '26 09:05

Jason



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!