Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

413
Views
Killing the current DoTween sequence

I am trying to run a DoTween and it runs well but when I want to stop it, it does not stop at all, it keeps running till it finishes. I am using the DoTween Sequence to kill it but somehow it is not working. What is the issue?

public float prevValue = 0;
Sequence mySequence = DOTween.Sequence ();

    private void Update () {
        UpdateSlider ();
        if (Input.GetKeyDown (KeyCode.T)) {
            LerpToThis (90);
        } else if (Input.GetKeyDown (KeyCode.Z)) {
            KillSequence ();

        }
    }

 public void LerpToValue (float newValue) {
        float myValue = prevValue;

            DOTween.To (() => myValue , x => prevValue = x, newValue, 3.0f);

    }

    public void KillSequence () {
        mySequence.Kill ();
    }

over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

Apart from the fact that your code uses undeclared variables (like ShouldLerp_) and on pressing 'T' you call a different method than is shown in your excerpt, I'll assume your LerpToThis call also tweens using DOTween.To, but when you try to stop tweening you call mySequence.Kill() even though that sequence isn't the thing that is doing the tweening. So that's why the tween doesn't stop.

Call Kill() on the result of the DOTween.To() call, or give that tween an Id and call DOTween.Kill(id) instead.

over 4 years ago · Santiago Trujillo Report

0

frankhermes has said it all, I'm just elaborating the solution a bit:

Within the LerpToValue method, you create a Tween with the line

DOTween.To(() => myValue , x => prevValue = x, newValue, DurationFading);

The method DOTween.To does return an object of type Tween on which you can call Kill, i.e. first you add a declaration to your class

private Tween myTween;

Then you store the tween when you create it in LerpToValue

myTween = DOTween.To (() => myValue , x => prevValue = x, newValue, DurationFading);

And finally, in KillSequence (which you will want to rename, since, as frank mentioned, there is no sequence used) you call

myTween.Kill();

You can get rid of the DOTween.Sequence () entirely.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!