Demigiant Forum
Unity Assets => DOTween & DOTween Pro => Topic started by: Alex 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:
_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.
-
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?
-
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 =)
-
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
//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?
-
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.
-
Ok, that's the smartest thing to do ,thanks!