Search Unity

  1. We're looking for feedback on Unity Starter Kits! Let us know what you’d like.
    Dismiss Notice
  2. Unity 2017.2 beta is now available for download.
    Dismiss Notice
  3. Unity 2017.1 is now released.
    Dismiss Notice
  4. Introducing the Unity Essentials Packs! Find out more.
    Dismiss Notice
  5. Check out all the fixes for 5.6 on the patch releases page.
    Dismiss Notice
  6. Help us improve the editor usability and artist workflows. Join our discussion to provide your feedback.
    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,224
    Hello,

    after working a lot on it, DOTween, the sequel of HOTween, is now out.
    Compared to HOTween, DOTween is much more powerful, efficient, usable and has tons more features.
    Here's the website with documentation and downloads.
    And here's the new official forum.
    splash_dotween.png


    UPDATE
    DOTween Pro is now also out, with visual scripting editors and other cool stuff.

    [​IMG]
     
    Last edited: Apr 18, 2015
    AlenH, Gozdek, Crazydadz and 7 others like this.
  2. ZJP

    ZJP

    Joined:
    Jan 22, 2010
    Posts:
    2,612
    400% faster than HOTween!!!!!. Wow.... Good job. :)
     
  3. Izitmee

    Izitmee

    Joined:
    Jan 27, 2011
    Posts:
    3,224
    Hey ZJP, it's been a long time, glad to see you :) I am indeed very satisfied and shamelessly eager to replace HOTween in all my games: this is truly the engine I wanted to have since a long while.
     
  4. Dmitriy-Yukhanov

    Dmitriy-Yukhanov

    Joined:
    Jul 27, 2012
    Posts:
    664
    Yey, it finally reached public alpha, congratulations, Daniele! Lot of hard work behind.
    And I know what I'm saying watching dosens of those emails from Trello =)
    Spreading the world! =D
     
  5. woshihuo12

    woshihuo12

    Joined:
    Jul 18, 2014
    Posts:
    36
    DOTween requires Unity 4.5.2 or later

    can support unity4.3.4? why or why not??:D
     
  6. Izitmee

    Izitmee

    Joined:
    Jan 27, 2011
    Posts:
    3,224
    Yey! Billions of thank to you Dmitriy for all the help you gave me, and for not unsubscribing from Trello in spite of the megaspam xD

    @woshihuo12 The only reason is that Unity 4.5 introduced the new Time.unscaledDeltaTime, which is pretty useful with timeScale Independent tweens. I could actually support older versions by reverting to the old way (I just stored Time.realtimeSinceStartup and used that to calculate unscaled time), but I thought that almost no one would still use older Unity versions? Let me know: if I re-implement the old way it will be compatible even with Unity 3 :D
     
  7. minirop

    minirop

    Joined:
    Feb 15, 2014
    Posts:
    5
    consoles maybe? at least PSVita and WiiU use 4.3.4
     
  8. woshihuo12

    woshihuo12

    Joined:
    Jul 18, 2014
    Posts:
    36
    @woshihuo12 The only reason is that Unity 4.5 introduced the new Time.unscaledDeltaTime, which is pretty useful with timeScale Independent tweens. I could actually support older versions by reverting to the old way (I just stored Time.realtimeSinceStartup and used that to calculate unscaled time), but I thought that almost no one would still use older Unity versions? Let me know: if I re-implement the old way it will be compatible even with Unity 3 :D[/QUOTE]


    ;) if i can do next game, i will use 4.5 or later, so i just use hotween, it's enough for me!!!
    thank you ...
     
  9. Izitmee

    Izitmee

    Joined:
    Jan 27, 2011
    Posts:
    3,224
    Good point! Ok, later this afternoon I'm gonna update DOTween to support EVERYTHING :D
     
  10. Izitmee

    Izitmee

    Joined:
    Jan 27, 2011
    Posts:
    3,224
    Done already :)

    Latest update has a much wider compatibility range: Unity 3.5 or later (just because I couldn't check on Unity 3.0).
     
  11. woshihuo12

    woshihuo12

    Joined:
    Jul 18, 2014
    Posts:
    36
    static public void PlayOpenWindowAnim(Transform trans, Holoville.HOTween.Core.TweenDelegate.TweenCallback cb = null)
    {
    //HOTween.To(trans, 0, new TweenParms().Prop("localScale", Vector3.zero));
    //HOTween.To(trans, 0.25f, new TweenParms().Prop("localScale", Vector3.one).Ease(EaseType.EaseOutBack).OnComplete(cb));
    trans.DOScale(new Vector3(0, 0, 0), 0);
    trans.DOScale(Vector3.one, 0.25f).SetEase(Ease.OutBack);
    }

    i want a window show a tween. first the window is localScale zero so hide the window ,then use 0.25s set scale to one so show the window....
    but i change with dotween like above...
    but can't work very well...........
    so can help me??
    very thanks...
     
  12. Izitmee

    Izitmee

    Joined:
    Jan 27, 2011
    Posts:
    3,224
    @woshihuo12 Agh, the dreaded 0 duration tweens :D Download the new version (0.7.200) I just uploaded and your code will work :)
    Also, I added new shortcuts for FROM instead than TO tweens, so you could do the same in one line of code (assuming you just want to tween your window from 0 to its actual scale).
    Code (csharp):
    1.  
    2. trans.DOScaleFrom(Vector3.zero, 0.25f).SetEase(Ease.OutBack);
    3.  
     
  13. woshihuo12

    woshihuo12

    Joined:
    Jul 18, 2014
    Posts:
    36
    //HOTween.To(trans, 0, new TweenParms().Prop("localScale", Vector3.zero));
    //HOTween.To(trans, 0.25f, new TweenParms().Prop("localScale", Vector3.one).Ease(EaseType.EaseOutBack).OnComplete(cb));
    trans.DOScale(new Vector3(0, 0, 0), 0);
    trans.DOScale(Vector3.one, 0.25f).SetEase(Ease.OutBack);

    both easeOutBack, but the effect not same??why....
     
  14. woshihuo12

    woshihuo12

    Joined:
    Jul 18, 2014
    Posts:
    36
    static public void PlayCloseWindowAnim(Transform trans, DG.Tweening.Core.TweenCallback cb)
    {
    trans.DOScale(Vector3.zero, 0.25f).SetEase(Ease.InBack).onComplete = cb;
    //if (!HOTween.IsTweening(trans))
    //{
    // HOTween.To(trans, 0.25f, new TweenParms().Prop("localScale", Vector3.zero).Ease(EaseType.EaseInBack).OnComplete(cb));
    //}
    }

    and i also have a close tween...before i use HOTween.IsTweening(trans)) to judge the trans is tweening,
    so the tween will not repeat...
    in Dotween, how can i get this????
     
  15. CremaGames

    CremaGames

    Joined:
    Mar 5, 2014
    Posts:
    59
    Hey, great work man. We're using HOTween extensively in our current project.

    Are pluings supported right now? If not, will they be supported in the near future? We're using the PlugVector3Path to move our main character through a map.
     
  16. Izitmee

    Izitmee

    Joined:
    Jan 27, 2011
    Posts:
    3,224
    @woshihuo12 DOTween was using a different default overshoot for OutBack tweens. Just updated it so it's the same and both tween will play identically now.
    About IsTweening I'm working on it right now :)

    @CremaGames plugins are already supported: it's just that their API is now way more convenient. For example, to move a transform only on the Y axis with HOTween you do this:
    Code (csharp):
    1.  
    2. HOTween.To(myTransform, 1, new TweenParms()
    3.   .Prop(new PlugVector3Y("position", 45))
    4. );
    5.  
    while with DOTween you do this:
    Code (csharp):
    1.  
    2. myTransform.DOMoveY(45, 1);
    3.  
    or this, in case you prefer the generic way:
    Code (csharp):
    1.  
    2. DOTween.ToAxis(()=> myTransform.position, x=> myTransform.position = x, 45, 1).SetOptions(AxisConstraint.Y);
    3.  
    About PlugVector3Path I plan to add it in the next weeks, but it will probably be a "pro" feature (you can read about it here).
     
  17. CremaGames

    CremaGames

    Joined:
    Mar 5, 2014
    Posts:
    59
    Cool, we will wait a bit more in order to replace our HOTween integration then. Pro version sounds fine :)
     
  18. Izitmee

    Izitmee

    Joined:
    Jan 27, 2011
    Posts:
    3,224
    @woshihuo12 Voilà, IsTweening has been added too in v0.7.215. Here's the docs about it.
    P.S. it doesn't return a bool anymore though, but an int. So you'll just have to check if the result is > 0
     
  19. neonblitzer

    neonblitzer

    Joined:
    Aug 5, 2013
    Posts:
    11
    You're awesome! I've been reading the docs and it looks so GOOOOOD. (HOTween was already nearly perfect...)

    Though I think IsTweening should be renamed, as its name kinda implies that it returns a boolean value. At least that's what people are probably used to. Perhaps GetNumberOfTweens or something equally unwieldy? ;)

    And please write some tips on how the caching or reusing or storing or autokilling works. I'd love a concrete example, you know, "If you do this the same tweener is used again! And if you do this a new one is created!" I've just started storing and reusing HOTween tweeners and it seems that most of the manual stuff is now done behind the scenes. But how do I best use it? :)
     
  20. Izitmee

    Izitmee

    Joined:
    Jan 27, 2011
    Posts:
    3,224
    @neonblitzer Thank you! Glad you like it :)

    You're totally right about IsTweening. I will actually make it return a bool instead than changing the name (but tomorrow, after I finish implementing LoopType.Incremental), which seems to make more sense.
    About the cache, I updated the FAQ with a " how cache works" topic. Let me know if it's comprehensive enough or you think more informations are needed.
     
  21. Izitmee

    Izitmee

    Joined:
    Jan 27, 2011
    Posts:
    3,224
    v0.7.220 released.

    It adds LoopType.Incremental, DOTween.ClearCachedTweens, and now IsTweening returns a bool.
     
  22. fermmmm

    fermmmm

    Joined:
    Oct 18, 2013
    Posts:
    124
  23. Izitmee

    Izitmee

    Joined:
    Jan 27, 2011
    Posts:
    3,224
    Congratulations for finding the first bug! :) And yes, it was indeed a bug (which also led me to find another different one, so it was doubly cool).

    I fixed it in the latest v0.7.225.
     
  24. neonblitzer

    neonblitzer

    Joined:
    Aug 5, 2013
    Posts:
    11
    Nice, thank you for the response. Just changing end values seems very simple and powerful, especially with snapStartValue.

    The API on your site has the DOTween static public attributes' default values (for example defaultAutoKill = true), but they don't show on Visual Studio intellisense tooltips for some reason. :/

    And, PlayBackwards and PlayForward descriptions are mixed. :) Also, as with HOTween, the former has an "s" at the end (as I think it should) while the latter doesn't. http://english.stackexchange.com/questions/3885/forward-vs-forwards

    Does ChangeEndValue return void intentionally? Otherwise one could chain it with a Play call after it... Sorry for nitpicking like this :(
     
    Last edited: Aug 11, 2014
    CrazyCamel likes this.
  25. Jeiel

    Jeiel

    Joined:
    Apr 23, 2013
    Posts:
    7
    DORotate doesn't seem to support passing in Quaternions as the destination value and trying to use DOTween.To() with Quaternions gives me the following error in the editor:

    Cannot implicitly convert type `UnityEngine.Quaternion' to `float'

    And in Visual Studio, it says:

    Cannot resolve method 'TO(lambda expression, lambda expression, UnityEngine.Quaternion, float)'

    I'm using DOTween version 0.7.255
     
  26. Izitmee

    Izitmee

    Joined:
    Jan 27, 2011
    Posts:
    3,224
    @neonblitzer I love nitpicking so go for it, and thanks for pointing out the XML comments corrections.

    About Forward/s and Backward/s you're totally right, and indeed they are PlayForward and PlayBackwards as in HOTween: I erroneously added an S to Forward only on the website docs (or were you saying the opposite, meaning I should add an S even to Forward? that seems wrong to me, though even that link you sent is kind of confusing on the subject).

    About intelliSense and DOTween.defaultAutoKill (or others) can you tell me more? I see those static properties and their description both with Visual Studio's intelliSense and with MonoDevelop's, so it's weird that you don't. You don't see those properties at all, or you see them without a description?

    @Jeiel DORotate wants a Vector3 (both because like that it's easier to pass custom rotations and because internally Quaternions are rotated as Vector3). If you really want to pass a Quaternion, just pass myQuaternion.eulerAngles instead.
     
  27. Izitmee

    Izitmee

    Joined:
    Jan 27, 2011
    Posts:
    3,224
  28. RichHurst

    RichHurst

    Joined:
    Jul 25, 2013
    Posts:
    30
    This looks really great! I just have one question, is it ok to use the transform tween on kinematic rigidbodies with colliders? Or would it be better to tween a vector / float value with moveRotation in fixed update?
     
  29. Izitmee

    Izitmee

    Joined:
    Jan 27, 2011
    Posts:
    3,224
    Hi Rich. Should be ok, as long as it's kinematic and no physics mess up the animations.
     
  30. DavidDebnar

    DavidDebnar

    Joined:
    Mar 19, 2011
    Posts:
    113
    Loving the new stuff! I'm not sure if you've played with your own plugin much yet, but I was trying some experiments specifically with the ChangeEndValue, because I think it's the most powerful addition, anyway. What would, in your opinion, be the best way to make a cube follow another cube purely via DOTween? I tried a very witty approach, but it threw a stack overflow on me.:
    Code (CSharp):
    1. Tweener tweener = transfrom.DOMove (Target.position, 1).SetSpeedBased ();
    2. tweener.OnUpdate (() => tweener.ChangeEndValue (Target.position, true));
    In any case, thanks a LOT for a second iteration of this amazing plugin, I can't stress enough how amazingly easy it makes animations for a dumb programmer like myself!
     
    Last edited: Aug 11, 2014
  31. Izitmee

    Izitmee

    Joined:
    Jan 27, 2011
    Posts:
    3,224
    Hey Dávid! Glad you like it :) And I did that exact same test, but instead than using OnUpdate I used Unity's Update to have an object follow the mouse. With your way you found a bug where OnUpdate is called when it shouldn't and thus generates a stack overflow. It's an easy fix and I'll do that tomorrow morning among other things (going to bed now).
     
  32. RichHurst

    RichHurst

    Joined:
    Jul 25, 2013
    Posts:
    30
    Ok, thanks for the quick response...

    I tried it out and it does work well and seems much faster than itween, but I have encountered a small problem.

    I am using DoTween to move a series of platforms in a game. If I use the transform.DoMove shortcuts then the rigidbody character doesn't move with the platform (sort of slides on top). I think this is to do with rigidbodies should ideally be moved with the MovePosition command instead, so I used the float method and OnUpdate to call a function that uses the MovePosition to adjust its position. This does move the rigidbody character with the platform as expected, but I was wondering maybe a good feature would be to check if a gameobject has a rigidbody attached and if so to use the MovePosition / MoveRotation methods instead?

    Thanks

    Rich
     
  33. Izitmee

    Izitmee

    Joined:
    Jan 27, 2011
    Posts:
    3,224
    @RichHurst Good point Rich. I put it in my TODO list and will add it soon.

    @Dávid Debnár I went to fix that OnUpdate "issue", and realized that instead it's intended behaviour. I mean, you do want OnUpdate to be called when you change a start/end value, since a rewind happens and you might have other things to control related to that update, so preventing that to happen would not be good. Instead, I suggest you use Unity's Update to do a follow routine like that :)
     
  34. Izitmee

    Izitmee

    Joined:
    Jan 27, 2011
    Posts:
    3,224
  35. DavidDebnar

    DavidDebnar

    Joined:
    Mar 19, 2011
    Posts:
    113
    You can fix this with a quick shortcut ;)

    Code (CSharp):
    1. using UnityEngine;
    2. using DG.Tweening;
    3.  
    4. public static class RigidbodyShortcutExtensions
    5. {
    6.     public static Tweener DOMove (this Rigidbody rigidbody, Vector3 endValue, float duration)
    7.     {
    8.         return DOTween.To (() => rigidbody.position, rigidbody.MovePosition, endValue, duration).SetId (rigidbody);
    9.     }
    10. }
     
  36. Izitmee

    Izitmee

    Joined:
    Jan 27, 2011
    Posts:
    3,224
  37. RichHurst

    RichHurst

    Joined:
    Jul 25, 2013
    Posts:
    30
    Wow, thanks to both of you! This is really developing fast and looking great!

    Thanks once again.
     
  38. RichHurst

    RichHurst

    Joined:
    Jul 25, 2013
    Posts:
    30
    Just thought I'd let you know, I've now implemented the new version and it works really well (much faster than my crude implementation).

    I have another question / suggestion, would there be a way to have a delay option that works on the completion of each step, currently I am using the OnStepComplete to call a function that calls a coroutine that pauses the tween, waits for a given time and then resumes the tween. This works, but I imagine its not the most efficient way of doing it...

    I realise its probably quite a niche request, but i'd imagine its quite useful for people trying to implement platform tweens.

    Thanks

    Rich
     
  39. DavidDebnar

    DavidDebnar

    Joined:
    Mar 19, 2011
    Posts:
    113
    You could use a Sequence for this.
     
  40. RichHurst

    RichHurst

    Joined:
    Jul 25, 2013
    Posts:
    30
    OK, thanks... I'll look into using that instead.

    I might be doing something wrong (more than likely), but I couldn't get the DoLocalRotate to be rotating in local space?
     
  41. jagttt

    jagttt

    Joined:
    Nov 2, 2012
    Posts:
    10
    Thanks for you work. The new API looks fantastic. One question is that would web player platform be supported? It's not listed in supported platforms and I've tried it on a simple project seems it's not working on Web Player.
     
  42. Izitmee

    Izitmee

    Joined:
    Jan 27, 2011
    Posts:
    3,224
    I will have to make a special "tween master" badge just for you Dávid! Thanks a lot for the help here :)

    @RichHurst I just tested it, and DOLocalRotate works perfectly here and in the correct local space. Can you post an example code or an example barebone project to see why it's not working for you?

    P.S. here's a Sequence example as Dávid suggested:
    Code (csharp):
    1.  
    2. // Get a usable Sequence and set it to have infinite loops
    3. Sequence mySequence = DOTween.Sequence().SetLoops(-1);
    4. // Append a tween to it
    5. mySequence.Append(transform.DOMoveX(45, 1));
    6. // Add a 1 second pause at the end of the Sequence
    7. mySequence.AppendInterval(1);
    8.  
     
  43. Izitmee

    Izitmee

    Joined:
    Jan 27, 2011
    Posts:
    3,224
    @jagttt Glad you like it! I didn't mention the WebPlayer because I assumed it was obvious that everything worked there. And it was working up to a few versions ago, but now I see I broke something :O Gonna fix it immediately!
     
  44. Izitmee

    Izitmee

    Joined:
    Jan 27, 2011
    Posts:
    3,224
    Fixed the webplayer issue. It is apparently a Unity WebPlayer bug that doesn't like ?! ifs in one line inside the SetLoops method. It is very weird, since this works:
    Code (csharp):
    1.  
    2. if (t.tweenType == TweenType.Tweener) {
    3.   if (loops > -1) t.fullDuration = t.duration * loops;
    4.   else t.fullDuration = Mathf.Infinity;
    5. }
    6.  
    while this doesn't:
    Code (csharp):
    1.  
    2. if (t.tweenType == TweenType.Tweener) t.fullDuration = loops > -1 ? t.duration * loops : Mathf.Infinity;
    3.  
    Anyway, latest update (v0.7.270) fixes it. Too bad DOTween's download page is currently undergoing an internal server error (argh!). You can find latest version attached here anyway.
     

    Attached Files:

  45. RichHurst

    RichHurst

    Joined:
    Jul 25, 2013
    Posts:
    30
    Thats great, thanks for the example and once again much tidier and feels quicker!

    I went back and revisited what I was trying to do and I think I had my understanding of localSpace slightly wrong. I presumed it would just rotate along the given axis ignoring the world space, but I hadn't created its own localSpace by placing it inside another object. Once I had done this and rotated the parent object, it all worked as expected... So I'm sorry for being an idiot and getting it wrong... Unfortunately, its another case where if I do use the transform rotation it slightly messes with the physics, but as far as I am aware I don't think there is a MoveRotation in localSpace so I'm not entirely sure how to solve that other than using iTween for this scenario.

    I think my main confusion came from where I am attempting to replace iTween for DoTween, for some reason iTween will allow me to rotate the y axis of an object and it will rotate around that axis, even if I rotate the z axis prior. You can see in the editor it appears to be adjusting x,y,z rotation and even z position to compensate, but in the camera view everything looks as expected (an object rotated 90 degrees around its z axis (static), spinning 360 degrees around its y axis...)

    Anyway, sorry once again for my poor understanding and I'm really impressed with the library and support for this!
     
  46. DavidDebnar

    DavidDebnar

    Joined:
    Mar 19, 2011
    Posts:
    113
    I won't fight it :rolleyes:

    @RichHurst That's actually a confusing, albeit fair point! I've ran some tests and I have to ask: @Izitmee When using Quaternions, what's passed into the setter? I created a lambda, which debugs the quaternions euler angles and it seems it's a local to world type of thing, I may be wrong though.
     
  47. Izitmee

    Izitmee

    Joined:
    Jan 27, 2011
    Posts:
    3,224
    Actually, implementing a DOLocalRotate or a DOLocaMove for a rigidbody too shouldn't be complicated. I'll see if I can manage tomorrow.

    Instead, I'm very confused about the rest of the "local rotate alternate concept" and I understood nothing of it (but I'm very sleepy now) :B Can you explain better?

    Dávid to the setter I pass a Quaternion, but I actually tween a Vector3 in the background and convert it to Quaternion just before setting it. That's because tweening a Quaternion is crazy for many reasons, plus tweening a Vector3 also allows rotations that go beyond 360°. That said, I don't do local to world type of thing at all.
     
  48. DavidDebnar

    DavidDebnar

    Joined:
    Mar 19, 2011
    Posts:
    113
    @Izitmee Hm, that's odd. What I did in my experiment is this:
    [​IMG]
    I rotated the cube by 90 degrees along its Z axis, which made its Y axis point to the side. I tried both DORotate and DOLocalRotate with a Vector3 (0, 90, 0) endValue and the outcome wasn't as expected.
     
  49. Izitmee

    Izitmee

    Joined:
    Jan 27, 2011
    Posts:
    3,224
    I just tried that same thing, and results were as expected, so I'm even more confused now. Could you write me the code you used and what you would expect instead of what happens?

    Mhmm unless maybe I understood what you're thinking and we're confusing the Unity axis shown in the Scene view (the one that rotates with its object and is shown when selecting the "Local" button in the toolbar) with what transform.localRotation is? LocalRotation (which is what I use with DOLocalRotate) is a value relative to a transform's parent, and has no difference with rotation when used on a transform that has no parent, or whose parent is not rotated somehow. Did I get it? Let me know. If so, I think I could actually implement what you have in mind. If instead you meant something different and there's a bug I can't replicate let me know so I can crush it :D
     
  50. DavidDebnar

    DavidDebnar

    Joined:
    Mar 19, 2011
    Posts:
    113
    Yes - my nomenclature got confused by RichHurst! :( It'd be a lovely feature though ;)