Reusing sequences
« on: December 11, 2015, 11:51:17 PM »
I have a bit of a unique use case that I'm trying to get to work with DOTween Pro and the visual editor. I'm building an animation sequence tool (called SequenceManager from now on) that allows me to chain Unity animations and DOTweens, while syncing audio playback. Users specify an animation sequence length, and a type for each sequence (Unity animation or DOTween). If the user selects DOTween, they can specify the number of DOTweenAnimations for this stage of the sequence (see the attached screen shot). User's would then add a DOTweenAnimation script to the component, and drag that script into the SequenceManager to create a reference.

Once the SequenceManager Start function is called, I call DOTween.Sequence() and append the tween from each DOTweenAnimation for my animation sequence. Everything works great the first time I execute the DOTween Sequence. Tweens have AutoPlay and AutoKill disabled so that I can control when to trigger playback and to replay the tweens. However, on replaying the tweens I have a problem.

All my Move tweens start from the ORIGINAL location of the gameobject transform they are attached to. So, let's say I have an object at (0,0,0) and I tween to (50,50,0). Once the tween is done, I set the gameobject's position to be (100,50,0). If I restart my tween, instead of starting at (100,50,0) and tweening to (50,50,0), my game object starts at (0,0,0) and tweens to (50,50,0).

Is it possible to configure a reusable sequence such that tweens begin in the current state of a game object, instead of the original state of the game object? If so, what do I have to do to make this happen?

The main reason I purchased the DOTween Pro was to utilize the visual tween editor, but it seems like the only way to do what I want is by constructing new tweens in code everytime I need a new sequence. Is there something that I am missing?

Thank you!

*

Daniele

  • Dr. Admin, I presume
  • *****
  • 378
    • View Profile
    • Demigiant
Re: Reusing sequences
« Reply #1 on: December 12, 2015, 03:13:53 AM »
Hi!

On single DOTweenAnimations that are set as relative you can call Restart(true) to make them restart from the point where they are. But if you put them in a Sequence I'm afraid that's not possible, because a Sequence behaves like "fixed" movie timeline. That is by design, since tweens in a Sequence are often dependent on the other nested tweens, so changing them would break the Sequence.

That said, just to give it a try, tomorrow I'll tinker a little and see if I can find a solution, but I'm really not sure it can be done.

Cheers,
Daniele

Re: Reusing sequences
« Reply #2 on: December 13, 2015, 07:26:42 PM »
Thanks for the quick reply!

If I recreate the sequence with the editor set DOTweenAnimations each time I need to run the sequence, would that work? Otherwise, if there was a way to quickly duplicate a tween, I could also dynamically reconstruct everything. Essentially, I could use the DOTweenAnimation designed in the editor as a template tween that I reinstantiate every time I need its behavior.

This is a bit of a unique use case, so I might be asking about features that don't typically fit into a tween system. Thanks!