Create a paused sequence
« on: December 01, 2015, 03:54:10 PM »
Hi, for a while I was doing this to create a paused sequence, which I start later and restart to use it again:

Code: [Select]
_sequence = DOTween.Sequence()
    .SetAutoKill( false )
    .Append( DOTween.To( ... ) )
    .Pause();

// later....

_sequence.Restart();

// even later after it was finished

_sequence.Restart();

Is something wrong with that approach? I like to reuse the sequence, because I use it for scaling the same object, and I like to go back to its original scale before playing the tween again, this is why I have the Restart().

For some reason it does not work anymore... after calling Pause() the tween starts playing anyway.

*

Daniele

  • Dr. Admin, I presume
  • *****
  • 378
    • View Profile
    • Demigiant
Re: Create a paused sequence
« Reply #1 on: December 01, 2015, 05:43:59 PM »
Hi,

That's a good approach and I use it all the time (I even made Pause return a Tween/Sequence object so that you can chain stuff to it directly) and everything works here. Are you sure you're not calling Play or Restart somewhere else?

Cheers,
Daniele

EDIT: Or maybe by mistake you added the pause to one of the nested tweens instead of to the Sequence?

Re: Create a paused sequence
« Reply #2 on: December 01, 2015, 05:49:58 PM »
Hey, thanks for the fast reply. Good to know this is a common approach.

It is a bigger project and I might have overseen something. In a small test project it actually worked now as expected.
Thanks =)

Re: Create a paused sequence
« Reply #3 on: January 05, 2016, 08:13:47 PM »
Do created, stored in vars Tweens and then appended to a Sequence started when the var is created or in the order of the sequence?, example
Code: [Select]
//move player from position to the ball
            Tween twPlayerMove = player.transform.DOMove(
                tBall.position + Vector3.up * 0.7f - Vector3.forward,
                 distance * deltaTime
            ).SetEase(Ease.Linear);
            //change player animation speed with movement acceleration (simulation)
            twPlayerMove.OnUpdate(() =>
            {
                player.animation.clip.frameRate = twPlayerMove.ElapsedPercentage() * 60f;
            });
            seq.Append(twPlayerMove);

is this Tween already started before appended or does it start inside the sequence?

*

Daniele

  • Dr. Admin, I presume
  • *****
  • 378
    • View Profile
    • Demigiant
Re: Create a paused sequence
« Reply #4 on: January 05, 2016, 08:20:54 PM »
As long as you create a tween and add it to a Sequence within the same frame, the tween will not start and will be controlled by the Sequence play/pause state. If the tween starts instead, it won't be allowed to be added to a Sequence anymore.

Re: Create a paused sequence
« Reply #5 on: January 05, 2016, 09:15:43 PM »
Ok, that's the smartest thing to do ,thanks!