Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

416
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda