6
\$\begingroup\$

I am using DOTween, and I want to create a tweener, store it, and re-use it in the future several times.

    Tweener playerMoveUpTweener = player.transform.DOLocalMove(new Vector3(0,100,0), 0.5f, true);
    playerMoveUpTweener.SetEase (Ease.Linear);
    playerMoveUpTweener.SetRelative (true);
    playerMoveUpTweener.SetRecyclable (true);
    playerMoveUpTweener.OnComplete(() => {
        // some stuff
    });

But, in the future, I can't seem to be able to use it:

playerMoveUpTweener.Play();

Won't work. Not even with Rewind() or Restart().

Is it actually possible to re-use this same tweener?

\$\endgroup\$
6
  • \$\begingroup\$ I'm looking at the source code here: github.com/Demigiant/dotween/tree/develop/_DOTween.Assembly/… -- And there doesn't seem to be any easy way to reset a tween. Do you really need to use such a bloated tween engine? \$\endgroup\$
    – jgallant
    Commented Mar 1, 2016 at 12:55
  • \$\begingroup\$ @Jon well, I just happen to be used to it. Do you have any recommendations? \$\endgroup\$
    – Saturn
    Commented Mar 1, 2016 at 16:38
  • \$\begingroup\$ Based on the source code, it appears you may need to call Tweener.Setup() -- however, I am unsure. \$\endgroup\$
    – jgallant
    Commented Mar 1, 2016 at 16:39
  • \$\begingroup\$ @Jon I don't think I can call that. Looks like an internal method and can't be accessed from my scripts. \$\endgroup\$
    – Saturn
    Commented Mar 1, 2016 at 17:18
  • \$\begingroup\$ The reset command says this: // Doesn't reset active state, activeId and despawned, since those are only touched by TweenManager -- Doesn't reset default values since those are set when Tweener.Setup is called. You may have to do all this stuff manually -- Really not sure why this lib doesn't include a proper reset. \$\endgroup\$
    – jgallant
    Commented Mar 1, 2016 at 17:21

1 Answer 1

9
\$\begingroup\$

Tween is killed after it is completed, unless autokill is set to false.

playerMoveUpTweener.SetAutoKill(false);

Then use restart to play it again.

playerMoveUpTweener.Restart();
\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .