Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

DOTween (HOTween v2), a Unity tween engine

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

  1. Izitmee

    Izitmee

    Joined:
    Jan 27, 2011
    Posts:
    3,233
    Ahahahah! Glad we got un-confused

    What about the nomenclature for such a method? I might call it DOLocalAxisRotate? I'll have to think of something shorter.

    Why am I still awake! I'm crazy! I need to go to sleep! bye! :D
     
  2. jagttt

    jagttt

    Joined:
    Nov 2, 2012
    Posts:
    10
    @lzitmee Thanks for the quick response! I think it would be a good idea to put Web Player in the supported platforms, or it's a little bit of confusing :)
     
  3. RichHurst

    RichHurst

    Joined:
    Jul 25, 2013
    Posts:
    30
    @Izitmee @Dávid Debnár Sorry, didn't mean to cause confusion and I explained it in a rather lengthy confusing manner, the drawing idea was much clearer. It would be a handy feature though!
     
  4. Izitmee

    Izitmee

    Joined:
    Jan 27, 2011
    Posts:
    3,233
    Whew I wasted quite a lot of time trying to implement DOLocalAxisRotate but every method I tried failed some of the tests. But I will prevail! *_*

    @jagttt You're totally right and I did that now :)
     
  5. DavidDebnar

    DavidDebnar

    Joined:
    Mar 19, 2011
    Posts:
    113
    @Izitmee I know, it just won't budge, will it?! :confused: I tried to implement it myself, but failed and hence asked what was being passed into the setter, because I couldn't quite put my finger on the bug. Although! I smell, that AngleAxis is the right way to go :eek:
     
  6. Izitmee

    Izitmee

    Joined:
    Jan 27, 2011
    Posts:
    3,233
    Eheh the rotation system is pretty simple once you get the hang of it, and I implemented it already. To rotate around an object's local axis coordinates you just do:
    Code (csharp):
    1.  
    2. newRotation = transform.localRotation * desiredRotation;
    3.  
    The problem I have is that I can easily do that by applying a customized setter, but only when the tween is created, and thus the initial localRotation (which is used throughout the whole tween) is memorized immediately instead than when the tween starts up. Now I'm trying to find the best way to memorize it later, uff.
     
  7. DavidDebnar

    DavidDebnar

    Joined:
    Mar 19, 2011
    Posts:
    113
    @Izitmee Yes, exactly, that's why I tried using the AngleAxis instead of multiplying the localRotation, but I may be entirely wrong on this as I didn't get it to work. :oops:
     
  8. Izitmee

    Izitmee

    Joined:
    Jan 27, 2011
    Posts:
    3,233
    Mhmm I made some experiments with AngleAxis but it didn't work as intended at all. But I'm gonna try again then :)
     
  9. Izitmee

    Izitmee

    Joined:
    Jan 27, 2011
    Posts:
    3,233
  10. DavidDebnar

    DavidDebnar

    Joined:
    Mar 19, 2011
    Posts:
    113
  11. Izitmee

    Izitmee

    Joined:
    Jan 27, 2011
    Posts:
    3,233
    Wheee! :) In the end I used startLocalRotation * targetRotation, but implemented a system to take the starting localRotation only when it's needed and not when the tween is created. That allows Sequences to work correctly like this (Z then X then Y 90° rotation)

    2014-08-14_21-12-53.gif

    Code (csharp):
    1. DOTween.Sequence()
    2.   .Append(transform.DOLocalAxisRotate(new Vector3(0, 0, 90), 1))
    3.   .Append(transform.DOLocalAxisRotate(new Vector3(90, 0, 0), 1))
    4.   .Append(transform.DOLocalAxisRotate(new Vector3(0, 90, 0), 1));
     
    Last edited: Aug 14, 2014
  12. DavidDebnar

    DavidDebnar

    Joined:
    Mar 19, 2011
    Posts:
    113
    I just cried a little. Amazing beautiful job! I suppose I have to donate now. :rolleyes: :)
     
  13. RichHurst

    RichHurst

    Joined:
    Jul 25, 2013
    Posts:
    30
    You sir, are a genius! That's really cool and to be totally honest I think this rotation system would be very relevant to a lot of people. Unity's rotation system always seemed a little strange to me as I felt it should work more like this.

    This sounds really cheeky given all the work you have just done on this (and feel fairly responsible), but is it possible to have it use the MoveRotation method for rigidbodies too? Or would it be too much trouble for such a niche problem?

    Seconded about donation, although I was planning on purchasing the pro version (am I right in thinking this would include path tweening or did I imagine reading that?)
     
  14. DavidDebnar

    DavidDebnar

    Joined:
    Mar 19, 2011
    Posts:
    113
  15. rakkarage

    rakkarage

    Joined:
    Feb 3, 2014
    Posts:
    683
    No fancy editor like hot? Thanks
     
  16. Izitmee

    Izitmee

    Joined:
    Jan 27, 2011
    Posts:
    3,233
    I'm so glad you guys like this rotation system so much :) And now that I see it, I find it very useful too and don't know why I didn't implement it from the beginning. And @RichHurst you're right and I just forgot: next update I'm gonna implement DOLocalAxisRotate for rigidbodies too.

    EDIT: ooops forgot to mention that yes, as the masterful Dávid linked, pro version will have the path plugin, maybe other additional features, and some advanced downloadable examples.

    @rakkarage I don't plan (at least for now) to make a visual editor like hot, but @Dávid Debnár mentioned that he might make one in the future ;)
     
    Last edited: Aug 14, 2014
  17. Izitmee

    Izitmee

    Joined:
    Jan 27, 2011
    Posts:
    3,233
    P.S. I don't know if you noticed, since I never mentioned it, but if you click on the [DOTween] gameObject while playing in Unity Editor, the Inspector will show various infos about it (I will add more stuff there in the future):

    2014-08-15 00_53_55-Unity - Basics.unity - UnityTests.Unity4 - Web Player_.png
     
  18. RichHurst

    RichHurst

    Joined:
    Jul 25, 2013
    Posts:
    30
    @Izitmee Thats great news, looking forward to the update, thanks... do you have any rough time scale for when the pro version may be released?

    @Dávid Debnár I didn't think I completely imagined it!
     
  19. Izitmee

    Izitmee

    Joined:
    Jan 27, 2011
    Posts:
    3,233
    I hope to have the pro version for the middle of September, but it's a very rough time for me now so I can't tell for sure.
     
  20. RichHurst

    RichHurst

    Joined:
    Jul 25, 2013
    Posts:
    30
    Cool, Thanks... Don't worry, I wont hold you to that! :D
     
  21. Izitmee

    Izitmee

    Joined:
    Jan 27, 2011
    Posts:
    3,233
    New update (0.7.310) implements some major changes (and new features).

    Since I was asked to make it optional, now tweens are not recycled by default anymore. Instead, you can choose how recycling will happen, either when calling DOTween.Init or by changing DOTween.defaultRecyclable or by setting the recycle behaviour for each specific tween via SetRecyclable.

    Other than that there is a new OnKill callback, DOLocalAxisRotation for rigidbodies, and some bugfixes.
     
  22. fermmmm

    fermmmm

    Joined:
    Oct 18, 2013
    Posts:
    129
    Thanks for that fix, now my game works perfect, I have a question, does HOTween have instance recycling? because I had a problem with HOTween with tweens not being Killed after I call Kill, and with DOtween the problem is gone, maybe it was related.
     
  23. jvt619

    jvt619

    Joined:
    Jul 4, 2013
    Posts:
    53
    WOW! It's simpler than HOTween. Gonna try this
     
  24. jodev

    jodev

    Joined:
    Apr 16, 2013
    Posts:
    4
    Not sure if I am doing something wrong, but is it correct that the OnComplete callback of tweeners and sequences are not called when playing backwards?
     
  25. Izitmee

    Izitmee

    Joined:
    Jan 27, 2011
    Posts:
    3,233
    @jodev Yes it is correct. The OnStepComplete callback is called even when going backwards, but OnComplete is meant to be called only when the tween is complete as in "the end value has been fully applied".
     
  26. Izitmee

    Izitmee

    Joined:
    Jan 27, 2011
    Posts:
    3,233
    @fermmmm Nope HOTween didn't have recycling, so that must be a different bug. I'll investigate.
     
  27. jodev

    jodev

    Joined:
    Apr 16, 2013
    Posts:
    4
    Thanks for the lightning quick reply Izitmee. OnStepComplete does indeed fire the callback.

    That said, I'm not sure if this behavior is clear. The documentation for OnComplete says it "will be fired the moment the tween reaches completion, all loops included". Intuitively I would say that the word completion would mean the tween ending a playback state. The "end value" as you mentioned above would in this case refer to the starting position, as that is the end of the tween in a backwards playback.

    Because OnStepComplete does fire while playing backwards (even though the documentation is worded quite similar), I feel that OnComplete should be called when playback is done completely, regardless of the playback direction.

    Just my two cents.
     
  28. Izitmee

    Izitmee

    Joined:
    Jan 27, 2011
    Posts:
    3,233
    You're right, I didn't think about that, thanks for the feedback.

    I actually don't want OnComplete to fire when playing backwards, because that would actually lead to unintended calls (like when you do Rewind a tween, and find yourself with an OnComplete call). Also, OnComplete is practical to add operations that you want to call based on the end values of a tween. Instead, I will change the XML comments and docs to make the distinction between OnStepComplete and OnComplete clearer. Added that to my TODO for tomorrow or Monday (first I want to finish a kinda complex Shake/Punch system I'm working on).
     
  29. renman3000

    renman3000

    Joined:
    Nov 7, 2011
    Posts:
    6,527
    Hi @Izitmee, as a HOTween user I am very excited by this. I just have gone over the website and it looks great. Not only performance but I am excited about all these shortcuts.

    What I am struggling to figure out is Sequence. Can you give a real world example of when you might use this? And its effct?
     
  30. DavidDebnar

    DavidDebnar

    Joined:
    Mar 19, 2011
    Posts:
    113
    @renman3000 A real world example:


    @Izitmee Hey! I've almost finished writing a brand-new editor for DOTweena and I noticed, that you have DOTween.defaultAutoPlay but no Tween.SetAutoPlay (). Is this an oversight or is it deliberate?
     
  31. renman3000

    renman3000

    Joined:
    Nov 7, 2011
    Posts:
    6,527
    Thanks David, but how is that not just three Tweens, ran in succession? Or is that just it? Group tweens together, Vs using onComplete? Also, that OnComplete limits the tween. sequence is thus much more flexible?
     
  32. DavidDebnar

    DavidDebnar

    Joined:
    Mar 19, 2011
    Posts:
    113
    @renman3000 It's not just it, that's the whole point - controlling a number of tweens, delays and callbacks as one.
     
  33. renman3000

    renman3000

    Joined:
    Nov 7, 2011
    Posts:
    6,527
    So, create a sequence. Go figure. Must the tweens run in succesion or can you run two at once with in a sequence? I know that might be a bit tricky and impractical.
     
  34. DavidDebnar

    DavidDebnar

    Joined:
    Mar 19, 2011
    Posts:
    113
  35. renman3000

    renman3000

    Joined:
    Nov 7, 2011
    Posts:
    6,527
    Wow,
    So one line per tween, under one sequence, plus the insert, allows each tween to run in succession with the one insert running thru the whole sequence. Wow. Think this is a tween game changer?
     
  36. renman3000

    renman3000

    Joined:
    Nov 7, 2011
    Posts:
    6,527
    Ps.
    Since he has set up shortcuts, it seems Tweeners do not always need to be defined. If this is true, are we saving memory?


    Edit,
    Just noticed you can set the amplitude of an elastic ease. This is very handy as sometime the elastic is the right effect but the amplitude is too heavy. Well done.
    :)
     
  37. Izitmee

    Izitmee

    Joined:
    Jan 27, 2011
    Posts:
    3,233
    Another highfive to you for the explanations Dávid :)

    And hey Ren! Yes, we are saving a lot of memory and GC allocations compared to HOTween.
     
    renman3000 likes this.
  38. Izitmee

    Izitmee

    Joined:
    Jan 27, 2011
    Posts:
    3,233
    Oops forgot to answer your question Dávid. I didn't implement a SetAutoPlay because it felt kind of redundant. But I did implement a chainable Pause and a chainable Play, so you can always do:
    Code (csharp):
    1. transform.DOMove(45, 1).Pause();
    or
    Code (csharp):
    1. transform.DOMove(45, 1).Play();
     
  39. renman3000

    renman3000

    Joined:
    Nov 7, 2011
    Posts:
    6,527
    Awesome idea dude.
    I have been going over the documentation. What a great idea.

    Super excited.
     
  40. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,191
    Hi, we're using Hotween currently, which is awesome. Can you tell me how, with Dotween, one would decide whether to recycle tweens or not? Is recycling better performance?
     
  41. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,191
    Never mind, found that answer on your site. I don't suppose you'd write a shortcut for Tweening a LocalScale? That's usually what we always use.
     
    Last edited: Aug 19, 2014
    renman3000 likes this.
  42. Izitmee

    Izitmee

    Joined:
    Jan 27, 2011
    Posts:
    3,233
    Just to resume the recycling question. Recycling is better performance because a recycled tween doesn't generate GC allocations when created, and is slightly faster at startup. Though if working with less then hundreds of tweens it's not really noticeable. The con is that with recycling you might be storing a reference to a tween that has been killed and is now being used by something else.

    DOScale already uses localScale. I didn't add a "local" to the name because lossyScale is a completely different matter than global scale. I just updated the docs to make it more clear.
     
  43. Izitmee

    Izitmee

    Joined:
    Jan 27, 2011
    Posts:
    3,233
    zyzyx likes this.
  44. VeTaL

    VeTaL

    Joined:
    Jul 2, 2012
    Posts:
    125
    Great! Any chances to get DOShakeScale() for objects (not only camera)?
     
  45. Izitmee

    Izitmee

    Joined:
    Jan 27, 2011
    Posts:
    3,233
    @VeTaL I implemented shake only for camera because I didn't see a need for it elsewhere, but I surely could do it. Still, I have planned a DOPunch shortcut which will work with both scale, rotation and position. Maybe it already would do the trick?
     
  46. VeTaL

    VeTaL

    Joined:
    Jul 2, 2012
    Posts:
    125
    Sure, sounds great!
     
  47. smitchell

    smitchell

    Joined:
    Mar 12, 2012
    Posts:
    702
    tested with Unity5 ;) works great
     
    Izitmee likes this.
  48. Izitmee

    Izitmee

    Joined:
    Jan 27, 2011
    Posts:
    3,233
    New Update v0.7.425
    Adds transform.DoPunchPosition/Rotation/Scale, camera.DOShakeRotation, DOTween.Punch, DOTween.Shake, a virtual To tween, plus other minor features, optimizations and bugfixes

    @VeTaL the DOPunch methods should be what you were looking for

    @smitchell Great, thank you! :) I heard there are issues with WebGL export, but I'm waiting for the official Unity 5 release to see how it'll be, because those issues are not related to special classes but just to the way I use generics, so Unity should definitely fix them.
     
  49. VeTaL

    VeTaL

    Joined:
    Jul 2, 2012
    Posts:
    125
    Yaay!
     
  50. pixelballoon

    pixelballoon

    Joined:
    Mar 5, 2013
    Posts:
    11
    I've only been using DOTween for a couple of days so far, but first impressions - it's great! Really nice to use. Looking forward to the 'pro' version appearing on the asset store so I can throw some money your way.

    I'm going to add it myself for now, but might I suggest adding an extension method for DOShake* to transform? Personally, I find myself using shake for a lot of stuff outside of the camera movement, so it's quite useful to have that extension method in there.

    Also, I was just about to request it, but I've just spotted the custom SetEase function that supports a custom AnimationCurve, nice work!
     
unityunity