Demigiant / dotween

A Unity C# animation engine. HOTween v2
http://dotween.demigiant.com
Other
2.33k stars 348 forks source link

seq.InsertCallback(t, dosth) using as timer, short timer is getting later than the long timer. #564

Open atkdefender opened 2 years ago

atkdefender commented 2 years ago

Short timer is 1 Callback/1 second, Callback trigger another short timer. Long timer is 1 Callback/3 second, Callback trigger another long timer. Then the short timer is getting later and later. What should I do to align them?

Demigiant commented 2 years ago

Ahoy, Could you post me a code example so I can replicate this? I'm not here I get it 👀

atkdefender commented 2 years ago

Ahoy, Could you post me a code example so I can replicate this? I'm not here I get it 👀

public class TryShortLongTimer : MonoBehaviour
{
    Sequence seqShort, seqLong;

    // Start is called before the first frame update
    void Start()
    {
        TimerShort();
        TimerLong();
    }

    void TimerShort()
    {
        Debug.Log(Time.time.ToString("F3") + "  Short.");
        seqShort = DOTween.Sequence();
        seqShort.InsertCallback(1f, () =>
        {
            TimerShort();
        });
    }

    void TimerLong()
    {
        Debug.Log(Time.time.ToString("F3") + "  Looooooooooooong.");
        seqLong = DOTween.Sequence();
        seqLong.InsertCallback(6f, () =>
        {
            TimerLong();
        });
    }
}

Sorry for answering later. Codes above. In a clean empty project, every 10s get later about 0.016s. When it's using in my project, every 10s get later about 0.2s. That's a lot. (In my game, one timer is end, then find another skill, set different timer. Can't simply use "SetLoop(N)".)