Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

DOTween (HOTween v2), a Unity tween engine

Discussion in 'Assets and Asset Store' started by Demigiant, Aug 5, 2014.

  1. meapps

    meapps

    Joined:
    May 21, 2013
    Posts:
    167
    @Virdari Just when the Tween is complete create the same again.
    you also make an forever loop.
     
    Last edited: Sep 27, 2015
  2. Virdari

    Virdari

    Joined:
    Aug 19, 2014
    Posts:
    14
    I thought my code above does exactly that :S
     
  3. meapps

    meapps

    Joined:
    May 21, 2013
    Posts:
    167
    @Virdari if you got the DoTween Pro you dont need to use Coroutine for that. Just use DoTween Animation.

    For example you can play the Tween then if the gameobject is active.
     
  4. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    @deekpyro Ah, I see now. So you want your target(camera) to look at different points at each waypoint, but those points are not part of the path? If so, you would have to use the OnWaypointChange callback and create a separate DOLookAt tween when a new waypoint is reached.

    @meapps Glad you solved it. Can you tell me what issue in the latest DOTween Pro update was causing it? On what version are you now?
     
  5. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    @Virdari Other than a DOTweenAnimation, you can also just add a SetLoops(-1) at the end of the tween, and no need for coroutine. P.S. thanks for buying :)

    EDIT: this will run forever
    Code (csharp):
    1. transform.DORotate (newVector3 (0, transform.rotation.eulerAngles.y + 360, 0), 3, RotateMode.FastBeyond360).SetLoops(-1)
     
  6. deekpyro

    deekpyro

    Joined:
    Oct 16, 2012
    Posts:
    71
    @Izitmee Almost! I want to use the rotation of each waypoint on the path (no extra transforms are involved).
     
  7. meapps

    meapps

    Joined:
    May 21, 2013
    Posts:
    167

    @Izitmee DOTweenPro_0_9_340, some DoTween Animation were gone. The warning told me that i should click on the gameobject again but the settings were gone too.
     
  8. Virdari

    Virdari

    Joined:
    Aug 19, 2014
    Posts:
    14
    Thank you for your quick reply. I have another issue. Using your DOTween Pro Path Script for an UI element, The UI Panel ends up being rotated in the opposite direction to the camera. Using The Look At Transform Orientation setting. Adding the Camera for the LookAt Target. Is there a way to quickly fix this rotation issue?
     
  9. meapps

    meapps

    Joined:
    May 21, 2013
    Posts:
    167
    @Virdari you could use too an unity animation for that with an loop that easier then.
     
  10. abhijeet1001

    abhijeet1001

    Joined:
    Jan 6, 2015
    Posts:
    65
    Purchased TextMesh Pro today after reading Dotween Pro supports TextMesh Pro , but when trying to attach Dotween component to TextMeshPro object it says no suitable component Found in red color :( any ideas ? i am using the latest beta version of Text Mesh Pro , also the name of component is no longer TextMeshPro its TextMeshProUGUI
     
  11. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    @abhijeet1001 Hi, and thanks for buying the Pro. Did you run DOTween's setup (from DOTween Utility Panel)? That will activate the TextMeshPro additional animations.

    @Virdari I am not sure I understood the path issue. Can you whip up an example and send it to me?

    @deekpyro Ah, never thought of that. I'm afraid that can't be possible unless you use other objects to store the rotation. A Path's waypoint is not a gameObject, and has no transform nor rotation, so there's no way to know that.
     
  12. abhijeet1001

    abhijeet1001

    Joined:
    Jan 6, 2015
    Posts:
    65
    EDit ok i did the force resetup but now i get 8 Console error , no DOfade found no DoColor found n errors like that
     
  13. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    Oh wait! If you installed TextMeshPro AFTER DOTween, you have to reinstall DOTween too (because the TextMeshPro extensions were deleted to save space, if it wasn't found). Just reinstall DOTween Pro and re-run the Setup, and everything should work.
     
  14. abhijeet1001

    abhijeet1001

    Joined:
    Jan 6, 2015
    Posts:
    65
    thnx for quick reply but i deleted DOTween folder and reimported and still got the errors , but i managed to get stuff working , i just had to comment few lines which were causing errors ( about 8 lines as there were 8 errors )

    this is one of the line

    Code (CSharp):
    1.                 else if (t.IsSameOrSubclassOf(typeof(TextMeshPro))) tween = ((TextMeshPro)target).DOText(endValueString, duration, optionalBool0, optionalScrambleMode, optionalString);
    Assets/Demigiant/DOTweenPro/DOTweenAnimation.cs(250,99): error CS1928: Type `TMPro.TextMeshPro' does not contain a member `DOText' and the best extension method overload `DG.Tweening.ShortcutExtensions46.DOText(this UnityEngine.UI.Text, string, float, bool, DG.Tweening.ScrambleMode, string)' has some invalid arguments

    Assets/Demigiant/DOTweenPro/DOTweenAnimation.cs(250,99): error CS1929: Extension method instance type `TMPro.TextMeshPro' cannot be converted to `UnityEngine.UI.Text'


    i commented couple lines n m good now , as i only needed the Fade animation from dotween , but u might have to look into it if anyone else needs those dotext n docolor features .
     
  15. kobyle

    kobyle

    Joined:
    Feb 23, 2015
    Posts:
    92
    Heya,

    Could it be that a Sequence calls OnRewind twice? while of course doing only 1 rewind() call

    Koby
     
  16. Seith

    Seith

    Joined:
    Nov 3, 2012
    Posts:
    755
    @Izitmee Hi Daniele, quick question for you: I have a situation where I tween the scale of a UI control from 0 to 1 in 0.5 sec. But that tween could be interrupted with an order to scale the control back down to 0 in 0.2 sec.

    But of course then I run into an obvious issue, which is the control hasn't finished scaling up to 1 when it is told to scale back down to 0 very quickly. So what happens as a result is the control starts to scale from 0 to 1, but then in the middle it's going to scale back down to zero very quickly, and then it will finish scaling up to 1.

    So I'm sure I'm not using DOTween properly! :) In other words, how can I automatically get an object to interrupt its tweening and most importantly forget about its previous tween command?

    I guess I'm simply looking for a way to get an object to only obey its latest tween command...
     
  17. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    @Seith Heya! You have two options:
    1. Kill the previous tween (you can either use a tween reference with myTween.Kill(), give that tween an ID and use DOTween.Kill(id), or use the direct target shortcut myUIControl.DOKill() to kill all tweens with that target)
    2. Store the tween and just play the same one backwards when you want to scale it down, forwards when you want to scale it up, which is indeed the cleanest and most efficient way. Also, if you want the tween to happen more quickly, you can change the tween's timeScale at any time :)
    @kobyle I just checked and here it's called correctly only once.

    @abhijeet1001 That is very weird. If you have the time and the chance, could you send me a link via private message with your project, so I can see what's happening (here everything's alright).
     
    Seith likes this.
  18. Seith

    Seith

    Joined:
    Nov 3, 2012
    Posts:
    755
    That worked great (I'm lazy so I used the DOKill option)! Thanks Daniele! :)
     
  19. kobyle

    kobyle

    Joined:
    Feb 23, 2015
    Posts:
    92
    Heya,

    Been struggling with this:
    Code (CSharp):
    1. DOTween.Sequence().Append(transform.DOLocalMoveY(0.16f, 0.45f).SetRelative(true))
    2.                   .Append(transform.DOLocalMoveY(-0.16f, 0.45f).SetRelative(true)).SetLoops(-1)
    DOTween.Kill(transform);
    transform.DOKill();

    This wont kill the sequence, and I dont want to keep a member or a reference to that sequence.
    Any other way of killing it?
     
  20. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    Hiya,

    a Sequence doesn't have a target (because you could add tweens with multiple targets inside), so you'll have to store that Sequence and kill it directly, or if you don't want to do that you can give it an ID and use DOTween.Kill(ID);
     
  21. kobyle

    kobyle

    Joined:
    Feb 23, 2015
    Posts:
    92
    Hey again,

    Sorry for the long question,

    Code (CSharp):
    1.  
    2. openSequence.AppendCallback(() => Fader.FadeIn(i_FadeInDuration));
    3. openSequence.AppendCallback(() => DOVirtual.DelayedCall(i_FadeInDuration, () => CloseCurrentMenuItem()));
    4.  
    What I try to do here is calling Fader.FadeIn and have the sequence wait the i_FadeInDuration, before calling CloseCurrentMenuItem().
    Is there a simple way to achieve this? (Fade.FadeIn returns immediately)

    Perhaps, is it possible to append a call to a function that will wait for the destination function completion (sync call) before continuing the sequence? (or does it contradict the all idea of the sequence callback?)

    One more thing.. I have tried the following:
    Code (CSharp):
    1. Sequence openSequence = DOTween.Sequence();
    2.  
    3. openSequence.AppendCallback(() => { Debug.Log("exec1"); })
    4.             .AppendCallback(() => { Debug.Log("exec2"); })
    5.             .AppendCallback(() => { Debug.Log("exec3"); });
    result:
    exec3
    exec2
    exec1

    is this an expected result?

    Thanks!
    Koby
     
    Last edited: Oct 5, 2015
  22. dl_studios

    dl_studios

    Joined:
    Oct 14, 2012
    Posts:
    76
    @Izitmee Hi, just following up to see if you had time to look at the rotation/gimbal lock issue. Thanks.
     
  23. Virdari

    Virdari

    Joined:
    Aug 19, 2014
    Posts:
    14
    Hey @Izitmee, got another question for you:
    This time I want something to drop down, something like this:
    Code (CSharp):
    1. IEnumerator GoDown()
    2.     {
    3.         while (true) {
    4.             Tween mytween = transform.DOMoveY (transform.position.y - YSpeed, 1f, false).SetEase (Ease.Linear);
    5.             yield return mytween.WaitForCompletion();
    6.         }
    7.     }
    I put this inside a Coroutine that runs forever, I call mytween.WaitForCompletion() in the yield statement. The problem is that sometimes the gameobject won't move at all. I think something is wrong with the WaitForCompletion() yielding. Could it because of disabling the object while it's still inside the yield statement ? (because the objects get disabled as soon as they collide with the despawner object, could be that they get disabled at a time during the yield statement)
    EDIT: The code below seems to work fine. You see, If I set an infinite Loop, they just keep falling down even after being despawned and then spawned back. I need to tween it without using infinite loops so that, when the object gets despawned(disabled) Tween restarts. Or I have to add Some OnDisable() OnEnable() methods like below
    For now just going to do it the vanilla way by updating the transform inside Update(). It's still bugging me that the Coroutine method doesn't work though.

    Code (CSharp):
    1.  
    2. Tweener mytween;
    3. void Start(){
    4. mytween = transform.DOMoveY (-YSpeed, 1).SetEase (Ease.Linear).SetLoops (-1, LoopType.Incremental).SetRelative (true);
    5. }
    6. void OnDisable(){
    7. mytween.Rewind();
    8. }
    9. void OnEnable(){
    10.     if (mytween != null)
    11.         mytween.Play();
    12. }
    However I still don't get why Coroutine method is not reliable.
     
    Last edited: Oct 6, 2015
  24. l1kant

    l1kant

    Joined:
    Nov 9, 2012
    Posts:
    5
    Hi! Can anyone advise what would be the best solution for making endless loop with random delays?
    I've tried resetting delay with SetDelay in OnComplete callback, that is not seem to be working, the Delay function keeps initial values.
    Thank you!
     
  25. FamerJoe

    FamerJoe

    Joined:
    Dec 21, 2013
    Posts:
    193
    We have a debate in the office.. What is the correct pronunciation of DOTween?
     
    neonblitzer likes this.
  26. kobyle

    kobyle

    Joined:
    Feb 23, 2015
    Posts:
    92
    @l1kant

    That's how I would do it:

    Code (CSharp):
    1.  
    2. void Start ()
    3.     {
    4.         // Option A - Coroutine
    5.         //StartCoroutine(EndlessLoop1());
    6.  
    7.         // Option B - DOTween
    8.         EndlessLoop2();
    9.     }
    10.  
    11.     public IEnumerator EndlessLoop1()
    12.     {
    13.         // Do Stuff
    14.         {
    15.  
    16.         }
    17.  
    18.  
    19.         // Random Delay (1-5)
    20.         {
    21.             System.Random random = new System.Random();
    22.             int randomNumber = random.Next(1, 5);
    23.  
    24.             Debug.Log(string.Format("Wait for: {0} Seconds.", randomNumber));
    25.  
    26.             float before = Time.realtimeSinceStartup;
    27.  
    28.             yield return new WaitForSeconds(randomNumber);
    29.  
    30.             float after = Time.realtimeSinceStartup;
    31.  
    32.             Debug.Log(string.Format("Real Time Passed: {1}", randomNumber, after - before));
    33.  
    34.             StartCoroutine(EndlessLoop1());
    35.         }
    36.     }
    37.  
    38.     private void EndlessLoop2()
    39.     {
    40.         // Do Stuff
    41.         {
    42.  
    43.         }
    44.  
    45.         // Random Delay (1-5)
    46.         {
    47.             System.Random random = new System.Random();
    48.             int randomNumber = random.Next(1, 5);
    49.  
    50.             float before = Time.realtimeSinceStartup;
    51.  
    52.             DOVirtual.DelayedCall(randomNumber, EndlessLoop2)
    53.                 .OnStart(() =>
    54.                 {
    55.                     Debug.Log(string.Format("Wait for: {0} Seconds.", randomNumber));
    56.                 })
    57.                 .OnComplete(() =>
    58.                 {
    59.                     float after = Time.realtimeSinceStartup;
    60.  
    61.                     Debug.Log(string.Format("Real Time Passed: {1}", randomNumber, after - before));
    62.                 });
    63.         }
    64.     }
    65.  
    Hope this helps you out.

    Koby
     
  27. Ben-BearFish

    Ben-BearFish

    Joined:
    Sep 6, 2011
    Posts:
    1,204
    @Izitmee Do you know what would be the best way to implement an animating line with DOTween? I'm using Unity's UI in a 3D world canvas.

    By animating, I mean the line looks like it is being drawn. Kind of like an animated infographic.
     
    Last edited: Oct 6, 2015
  28. Virdari

    Virdari

    Joined:
    Aug 19, 2014
    Posts:
    14
    Ben if it's a UI object, use a mask to conceal your line, and then move either the mask or the object that is being masked so that line looks like it's being drawn. You could also play with it's alpha,(renderer.material.color.a) make it transparent first and then animate it's alpha value?
     
  29. Ben-BearFish

    Ben-BearFish

    Joined:
    Sep 6, 2011
    Posts:
    1,204
    That might work, but I think with multiple resolutions and complex animations that the masking technique might have issues. The alpha is an issue I think with the fact the alpha affects the whole line.

    @Izitmee Also, I'm receivng this error when building for WebGL. Which is related to the DOTween DLL. Does DOTween not support WebGL? I thought it did.

    Here's the specific error:
    EDIT: So I think this error is cause by having DOTween and DOTween Pro in the same project. I think WebGL doesn't know which OnComplete to call between the DLLs.

    EDIT 2: Removing DOTween Pro confirmed my suspicion. It now builds properly. @Izitmee can you check what's causing this issue between the 2 DLLs and try to resolve this issue? I'd prefer to use DOTween Pro in the WebGL build if possible.

    EDIT 3: Ok, so the issue is I'm using the latest version of DOTween with the latest DOTween Pro. If I use DOTween v1.0.850 with DOTween Pro v0.9.290 than the WebGL build will not build, but if I use the DOTween dll included with DOTween Pro the issue does not happen.
     
    Last edited: Oct 7, 2015
  30. abhijeet1001

    abhijeet1001

    Joined:
    Jan 6, 2015
    Posts:
    65
     
  31. hexdump

    hexdump

    Joined:
    Dec 29, 2008
    Posts:
    443
    Hi!,

    Is there any possibility to advance a tweener manually? I mean, I would like to create a tween and make start with an elapsed time of 1.0f instead of 0.0f. It is of use to me becasue I have an sprite going up and down in a infinite loop and sometimes it must be moved to another position, then reposition it to a given center and continue following the up and down tween. For this to work correctly I need to modify the starting elapsed time for the given animation.

    Cheers.
     
  32. CanisLupus

    CanisLupus

    Joined:
    Jul 29, 2013
    Posts:
    427
    Hi there, @Izitmee!

    1. We have a long DOTween.Sequence of animations. When we drag the mouse forward or backward, we move the sequence forward or backward in time. For that, we call the Goto method every frame and that's smooth.

    However, we also want to click on a certain point of a sequence (before or after the current time) and auto-animate to it. Well, we can also use Goto every frame for this, but is there something like a "SmoothGoto" method in DoTween that receives a time and a duration and animates the tween to the target time taking "duration" seconds? We couldn't find one. If not, do you think this would be a worthy addition to DOTween? ;)

    2. Is it by design that the Join method in a Sequence only joins the previous tween and never the previous callback/interval? For example, this:

    Code (CSharp):
    1.  
    2. DOTween.Sequence()
    3.    .Append(obj.DOLocalMoveX(-1000f, 2f).SetRelative()) // runs after 0s (immediately)
    4.    .Join  (obj.DOScaleX(2f, 2f))                       // runs after 0s (immediately)
    5.    .AppendCallback(() => print("callback"))            // runs after 2s
    6.    .AppendInterval(3f)                                 // runs after 2s
    7.    .AppendCallback(() => print("callback2"))           // runs after 5s
    8.    .Join  (obj.DOScaleY(2f, 2f))                       // runs after 0s (immediately)
    9.    .Append(obj.DOLocalMoveX(1000f, 2f).SetRelative()); // runs after 5s
    10.  
    I expected the second Join to join the previous instruction - an append - and run after 5 seconds, but it joins the previous tween, hence running from instant 0. Using v1.0.850.

    Thanks!
    - Daniel
     
    Last edited: Oct 8, 2015
  33. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    @dl_studios Hey, sorry if I'm being so slow, but these weeks are being crazy. Anyway, I managed to work on it, and while initially I was trying to implement a Vector3 solution, now I'm trying to do what you suggested, creating a Quaternion plugin. I have two full hours to work on it this morning and I hope to get it done, but if not I will persist even if a little slowly.

    You could Append an interval, like this:
    Code (csharp):
    1. openSequence.AppendCallback(() => Fader.FadeIn(i_FadeInDuration));
    2. openSequence.AppendInterval(i_FadeInDuration);
    3. // next
    Actualy yes. Since Callbacks have no "duration", if you append multiple of them at the same time it's like if you place them all together, and thus the order of the call will be random.


    @Virdari The issue there is that, if you disable the gameObject while the coroutine is running, the coroutine itself will be interrupted by Unity.


    Uhmmm never thought of that! You could create a single loop tween, and use a DOVirtual call to restart it after a random interval. Didn't test this directly, but it should work:
    Code (csharp):
    1. myTween t = transform.DOMoveX(2, 1).SetAutoKill(false);
    2. t.OnComplete(()=> DOVirtual.DelayedCall(Random.Range(1f, 10f, ()=> t.Restart())));

    I have no exact idea, even I sometimes pronounce it "DOH! tween!", others "Duː tween" :D


    @Ben BearFish It depends on how you draw the line. If you can draw it, DOTween's generic way can animate it, but I'm not sure what would be the best way to draw a UI line.
    About the WebGL error, DOTween Pro already contains DOTween, so maybe the real issue is that you have duplicate libraries? Let me know if it was a duplicate library issue or not.


    @hexdump Hi! You can just use Goto to send the tween at whichever position in time you prefer.


    @CanisLupus Hey!!!! :)

    I will have to think about implementing that, because it would need to create an additional variable in each tween class, which I'd like to avoid. In the meantime, you could use a trick (didn't test this directly but it should work). When launching a smooth-goto, you could add an OnUpdate call to the tween that will stop the tween when a given time is reached. Also, you could change the tween's timeScale to make it go there faster, and use the OnUpdate call to also reset the timeScale.

    Yes, but I'm not sure why I did that :D I checked and it's supereasy to allow AppenInterval to work with Join too, so I'm implementing it right now ;)
     
  34. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    @CanisLupus Mhmm I was implementing the Join thing, when I realized there might be some logical issues. In your example, instead of the second Join you could use an Append. So, if I allow Join to consider intervals too, we would have a case where Join and Append do the same exact thing. What are your thoughts?
     
  35. CanisLupus

    CanisLupus

    Joined:
    Jul 29, 2013
    Posts:
    427
    Long time no see (write?), @Izitmee ;) As always, thanks for the great support. :)

    OK, my example isn't all that great, but I'm thinking that Join and Append will only do the same thing in the case of an AppendCallback (because it is instant). Imagine there wasn't a second AppendCallback in my example. In that case, Join would come immediately after AppendInterval, so it would run after 2 seconds total (joining the interval). If instead of a Join you had an Append, it would run after 5 seconds (appending to the 2s+3s of the interval).

    I'm thinking of Appends like things that always set a new base for the following Joins, be them tweens appends, interval appends or callback appends. :)

    That said, there might be someone, somewhere, that has unknowingly put Joins after AppendIntervals or AppendCallbacks and got the right result for their case. Changing this would break those specific (hopefully rare) cases, but I think this change would make a lot of sense. Unless I'm missing some problem resulting from this change, of course! Do you see possible issues?

    - Daniel
     
    Last edited: Oct 9, 2015
  36. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    Eh, I missed your website corrections (but I hope I got better with that :)).

    Ah, now it makes more sense. So you're saying that it should work this way (in stub code):
    Code (csharp):
    1. mySequence
    2.    .Append(tween, 1) // plays immediately, lasts 1"
    3.    .AppendInterval(1)
    4.    .Join(tween, 1); // plays after 1", lasts 1"
    5. mySequence
    6.    .Append(tween, 1) // plays immediately, lasts 1"
    7.    .AppendInterval(1)
    8.    .AppendCallback(callback) // plays after 2"
    9.    .Join(tween, 1); // plays after 2", lasts 1"
    Right?
     
  37. CanisLupus

    CanisLupus

    Joined:
    Jul 29, 2013
    Posts:
    427
    No worries! ;)

    Assuming the second mySequence is a different sequence, then yes, that's exactly it.
     
  38. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    NEW DOTWEEN UPDATE v1.1.005
    • NEW: Added RectTransform.DOAnchorPosX/Y shortcuts
    • NEW: Added support for tweening double values
    • CHANGE: Sequence.Join now considers also the time insertion of callbacks
    Also, I updated the examples to show how to create custom DOTween plugins (to tween custom value types or do weird stuff).

    Damn! I had to go and make a type error with you, had I? :D Anyway, done!
     
  39. CanisLupus

    CanisLupus

    Joined:
    Jul 29, 2013
    Posts:
    427
    Haha you should have known :D Thanks a lot! :)
     
  40. Dan2013

    Dan2013

    Joined:
    May 24, 2013
    Posts:
    200
    @Izitmee

    DOTween is so useful... love it!!!
    I had a Pro license for a while.
    After using it for several days recently, I have some questions about it.

    1) What is the most appropriate way to reuse a created and saved tween?
    For example, I created a tween like:
    Tween tween = ObjX.transform.DOMoveX(10, 1).SetAutoKill(false);
    After the tween is completed, I change the transform of ObjX (e.g. to (0, 0, 0)),
    and I try to play the tween again by calling tween.Play(). But tween.Play() has no effect at all.
    I found tween.Rewind(true) works, which resets the position of ObjX before replaying the tween.
    I guess tween.Play() does not work because the tween is already in some "complete status"?
    I know that SetAs(tween/tweenParams) can reuse some parameters of a tween.
    But I also want to reuse the end value and duration of a tween.

    2) There is no SetAutoPlay(false) option for a tween instance?
    I see there is a global AutoPlay option, DOTween.defaultAutoPlay.
    Thus, if I want to create a new tween without auto playing it, I should do this below?
    Tween tween = transform.DOMoveX(10, 1);
    tween.Pause();


    3) When states (e.g. transform.x) of a tween/sequence start to update? in next frame?
    For example, these two snippets below should generate the same result?
    //snippet-1
    Sequence mySequence = DOTween.Sequence();
    mySequence.Append(transform.DOMoveX(10, 1))
    .Append(transform.DOMoveY(10, 1));

    //snippet-2
    Sequence mySequence = DOTween.Sequence();
    Tween tween1 = transform.DOMoveX(10, 1);
    Tween tween2 = transform.DOMoveY(10, 1);
    mySequence.Append(tween1)
    .Append(tween2);

    Based on two snippets above, intuitively, state updates of tween/sequence do not start during current frame when tween/sequence is created? State updates happen in the next frame (e.g. in next Update() or FixedUpdate())?
     
  41. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    @Dan2013 Hi! Glad you like this thingie, and thanks for getting the pro :)

    1) Once a tween starts, its start value becomes fixed to the starting value of the tweened object. You can change it with ChangeStartValue though.

    2) Exactly, and you can also write it in one line:
    Code (csharp):
    1. Tween tween = transform.DOMoveX(10, 1).Pause();
    3) Yes, the creation frame is considered the startup frame (and with a reason, because otherwise you would end up with incorrect animations), and you'll see the first movement happening in the next frame.
     
  42. Dan2013

    Dan2013

    Joined:
    May 24, 2013
    Posts:
    200
    @Izitmee
    Thanks for your answering.

    1) I am still not 100% sure what is the most appropriate way to reuse a created and saved tween?
    Let me change my question a little bit.
    Suppose I create a tween like: Tween tween = transform.DOMoveX(10, 1).SetAutoKill(false);
    After the tween is completed (X==10 is reached), the only way to reuse the tween is to call tween.Rewind()?
    Is it possible to reuse the tween by calling tween.Play()? with tween.ChangeValues()?


     
  43. Ben-BearFish

    Ben-BearFish

    Joined:
    Sep 6, 2011
    Posts:
    1,204
    @Izitmee Is there a way to tell a tween to PlayBack at a different duration when PlayBackwards is called?

    EDIT:
    Currently, I'm changing the Timescale on the tween, but I'm not sure if that's the best implementation for changing duration.
     
    Last edited: Oct 10, 2015
  44. CanisLupus

    CanisLupus

    Joined:
    Jul 29, 2013
    Posts:
    427
    Hey again! I just read this again: "CHANGE: Sequence.Join now considers also the time insertion of callbacks" and noticed that you don't mention intervals (just callbacks). We might have misunderstood something in each other's comments, but I thought appends of callbacks OR intervals would count. In fact, the first sequence in your stub code example still does not work as its comments say, in the new version. :)

    Try this:
    Code (CSharp):
    1. var seq = DOTween.Sequence();
    2. seq.Append(obj.DOLocalMoveX(-pos, 1).OnStart(() => print("expected 0, is " + seq.Elapsed())));
    3. seq.AppendInterval(2);
    4. seq.Join  (obj.DOScaleY(scale, 1).OnStart(() => print("expected 1, is " + seq.Elapsed())));
    It will print:
    Code (CSharp):
    1. expected 1, is 0.02
    2. expected 0, is 0.02
    3. // 0.02 or some other value close to 0. This was the first frame.
    Now, you might ask "but why would I want to join a tween to an interval?" and that would be a good question. After all, you could just do this instead:
    Code (CSharp):
    1. var seq = DOTween.Sequence();
    2. seq.Append(obj.DOLocalMoveX(-pos, 1).OnStart(() => print("expected 0, is " + seq.Elapsed())));
    3. seq.Append(obj.DOScaleY(scale, 1).OnStart(() => print("expected 1, is " + seq.Elapsed())));
    4. seq.AppendInterval(1);   // notice 1 instead of 2, because now we must subtract the scale tween's duration
    5. /* something else */
    Right. But consistency, I guess. ;)
     
  45. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    @Dan2013 I'm not sure I understood the question completely not even now, sorry. Let me see if I get it... To reuse a tween, as long as it's the same tween (same start and end value), you can rewind it, but also restart it, play it backwards, goto and things like that. If instead you want to change the start value, you should definitely use ChangeValues and then play it.

    @Ben BearFish Indeed changing the timeScale is the best thing to do, and the way I do that too. The duration is fixed because changing it would require to recalculate various things (like elapsed loops, which would be a logical chaos, or eventual speedBased duration).

    @CanisLupus Damn you're right. This Join modification got my feeble mind pretty confused and I missed that. Wanna try the attached update to see if everything's alright before I release it officially? :)
     

    Attached Files:

  46. CanisLupus

    CanisLupus

    Joined:
    Jul 29, 2013
    Posts:
    427
    I tested the example above, the same example in a loop, another one that involved an AppendInterval(0), and a few Joins separated by an AppendInterval/Callback. All worked like expected in that update, as far as I can tell. :)
     
  47. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    Wooooh got it!

    cyberman-victory-dance-o.gif

    Gonna add a couple more more things I'm working on and release it officially then :)
     
    CanisLupus likes this.
  48. abhijeet1001

    abhijeet1001

    Joined:
    Jan 6, 2015
    Posts:
    65
    How does the move/localmove wrks ? also whats the diff in move and local move ? i tried both and i dont notice any specific change also if i just try to move my object in x by typing TO : 1,0,0 in editor i notice my UI slightly moves in Z too
     
  49. JakeTBear

    JakeTBear

    Joined:
    Feb 15, 2014
    Posts:
    123
    @abhijeet1001 As far as I know, Local move will affect your LocalPosition. If you had an object you want to move around a parent object, you would achieve this by using local position instead of the absolute position.
     
    Demigiant likes this.
  50. Paulo-Henrique025

    Paulo-Henrique025

    Joined:
    Dec 12, 2010
    Posts:
    230
    @Izitmee Hi Daniele, another amazing asset made by you :D I helped you debugging HoTools on OSX a LONG time ago.

    Do I need pro to work with paths? I found the path class but it is buried deep down in 3 or 4 namespaces. If not can you give a quick sample?

    I want to make the change from iTween to DOTween, just missing the path animations, I am probably overlooking something here.