Demigiant / dotween

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

How to play the next tween in sequence before the previous one finished #574

Closed m64s closed 2 years ago

m64s commented 2 years ago

Hi Demigiant,

I'm trying to make a sequence and every tween in this sequence starts before the previous finish by "x" second, how i can do it?

m64s commented 2 years ago

also I'm trying to add more than one action for every gameobject, i want to play all the actions in the single game object at once time how I can do it using the sequence

here is the code:

 public void Play()
    {
        //Sequence sequence = DOTween.Sequence();

        for (int i = 0; i < countGos.Length; i++)
        {
            countGos[i].gameObject.SetActive(true);

            countGos[i].rectTransform.DOScale(1, 0.5f).SetDelay(i * timeSpace);// timeSpace = 0.45f
            countGos[i].DOFade(0, 0.75f).SetDelay(i * timeSpace);
        }

    }
mmeiburg commented 2 years ago

You can use .Insert(x, ...) where x is the duration where the tween should start.

For example. The following sequence moves the object 10 units in x direction for 0.5 sec. After 0.25 seconds the object scales to 10 for 0.5 sec. Then after the scaling the objects scales back to 1.

var seq = DOTween.Sequence();
seq.Append(transform.DOMoveX(10, 0.5f));
seq.Insert(0.25f, transform.DOScaleX(10, 0.5f));
seq.Append(transform.DOScaleX(1, 0.5f));
m64s commented 2 years ago

You can use .Insert(x, ...) where x is the duration where the tween should start.

For example. The following sequence moves the object 10 units in x direction for 0.5 sec. After 0.25 seconds the object scales to 10 for 0.5 sec. Then after the scaling the objects scales back to 1.

var seq = DOTween.Sequence();
seq.Append(transform.DOMoveX(10, 0.5f));
seq.Insert(0.25f, transform.DOScaleX(10, 0.5f));
seq.Append(transform.DOScaleX(1, 0.5f));

Thanks for your suggestion, it was helpful, also for anyone who wants to play multi-tweens at the same time in the sequence you can use seq.Join(transform.DoMove(pos, 1f)); after the appendix tween that you want to follow it.

here example.

http://forum.demigiant.com/index.php?topic=158.0