Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

418
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda