1. We've introduced thread tags, search within a thread and similar thread search. Read more here.
    Dismiss Notice
  2. Learn how you'll soon be able to publish your games to China in four simple steps with Xiaomi. Sign up now for early access.
    Dismiss Notice
  3. Get further faster with the Unity Plus Accelerator Pack, free for new Unity Plus subscribers for a limited time. Click here for more details.
    Dismiss Notice
  4. We've released our first Timeline Experimental Preview, our new tool for creating cutscenes and more! To check it out click here.
    Dismiss Notice
  5. Unity 5.5 is now released.
    Dismiss Notice
  6. Check out all the fixes for 5.5 in patch releases 1 & 2.
    Dismiss Notice
  7. Unity 5.6 beta is now available for download.
    Dismiss Notice

LeanTween - A tweening engine that is up to 5x faster than competing engines!

Discussion in 'Assets and Asset Store' started by dentedpixel, Dec 3, 2012.

  1. dentedpixel

    dentedpixel

    Joined:
    Jul 15, 2012
    Posts:
    653
    I have released an update to my animation/tweening engine: LeanTween.

    Updates include further optimised performance. It can be greater than 5x faster than the competing tweening engine iTween! I have a writeup comparing the speed of the two engines on my website.

    Also included in this update is the ability to have a custom tween function, created by passing an AnimationCurve to the engine.

    Download LeanTween for free from the Asset Store.
     
    Last edited: Nov 6, 2013
    f4bo and EMGPY like this.
  2. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    18,520
    What's all this free lark?!

    A rare thing these days, thank you for sharing with the community.

    Slapped it on my sig for a bit.
     
    Last edited: Dec 3, 2012
  3. ZJP

    ZJP

    Joined:
    Jan 22, 2010
    Posts:
    2,515
    And LeanTween VS HOTween?
    That said, thx.
     
  4. dentedpixel

    dentedpixel

    Joined:
    Jul 15, 2012
    Posts:
    653
    Hey thanks for the shout-out on the Signature Hippocoder.

    Good point ZJP. I'll have to update my write up comparing it to HOTween as well. When I started developing this, HOTween wasn't an option, so I am not that familiar with it, it looks like a better choice than iTween though (as far as speed goes).
     
    Last edited: Dec 4, 2012
  5. badawe

    badawe

    Joined:
    Jan 17, 2011
    Posts:
    297
    Looks amazing! I'm really want see this compared to HOTween! The iTween was dead to me a long time ago!
     
  6. dentedpixel

    dentedpixel

    Joined:
    Jul 15, 2012
    Posts:
    653
    It is also much faster than HOTween, but by a less drastic margin than iTween. In the same test HOTween had frame drops down to 15fps. I will update my article with screenshots of this soon.
     
    Last edited: Dec 4, 2012
  7. badawe

    badawe

    Joined:
    Jan 17, 2011
    Posts:
    297
    Amazing! This is really wellcome! Please update soon!
     
  8. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    1,056
    Will you add some playmaker actions ?
     
  9. GCat

    GCat

    Joined:
    Jul 31, 2012
    Posts:
    144
    seems interesting, but c# would be preferable
     
  10. I am da bawss

    I am da bawss

    Joined:
    Jun 2, 2011
    Posts:
    2,578
    Pure awesomeness! Thanks so much for this tool!


    EDIT: "Needs Unity Upgrade to 4.0" :(

    [​IMG]

    You made my kitten sad...


    Any chance this will be ported to Unity 3.5x? :D
     
    Last edited: Dec 4, 2012
  11. dentedpixel

    dentedpixel

    Joined:
    Jul 15, 2012
    Posts:
    653
    Lars - I am not sure what playmaker actions are, but i will look into it.

    GCat - You should be able to use this plugin just fine from a C# project. I will work on putting together an example project to illustrate it's use in C#.

    I am da bawss - Sorry for making your kitten sad :), you can also download it from Google Code at: http://code.google.com/p/leantween/downloads/list . The project may not open in Unity3.5, but you should be able to use the script just fine...
     
    Last edited: Dec 4, 2012
  12. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    1,056
    http://www.hutonggames.com/


    Playmaker is a unity visual scripting tool.
    You can ask Alex Chouls, the author and a unity forum member, he can give you all the details and probably a developer version of playmaker.
     
  13. dentedpixel

    dentedpixel

    Joined:
    Jul 15, 2012
    Posts:
    653
    Ok thanks Lars, that looks really neat. I will look into it.
     
  14. virror

    virror

    Joined:
    Feb 3, 2012
    Posts:
    2,760
    Nice, will keep this in mind if i need to tween anything : )
     
  15. Izitmee

    Izitmee

    Joined:
    Jan 27, 2011
    Posts:
    3,215
    Welcome to the tweeners club dentedpixel :)

    I was obviously curious and downloaded your test, then implemented HOTween. Ran it, and FPS seem to be exactly the same between LeanTween and HOTween (with LeanTween visually stuttering a little more, if my eyes didn't trick me), so maybe you set HOTween wrongly. Consider that:
    - HOTween uses an easeOutQuad easing by default, instead than the default linear one LeanTween uses
    - HOTween can be initialized too, to choose if you want to use an OverwriteManager or not. Using it obviously makes the framerate drop in case you have tons of tweens, like in your example. So I initialized it by disabling the OverwriteManager, since LeanTween doesn't have one, to have a fairer comparison.

    Note that I'm not saying this because I want to win the "tween competition", but just because I read your statement, felt curious, and found it wasn't right ;) Also, LeanTween seems to be a very different system than HOTween (more gameObject oriented), so it adds another degree of choice based on the tastes of the users, which is great. Congrats again :)
     
  16. dentedpixel

    dentedpixel

    Joined:
    Jul 15, 2012
    Posts:
    653
    Hey Izitmee, thank you for the welcome. I didn’t realize your engine used “easeOutQuad” as the default easing type, so I guess my initial test wasn’t too fair. This did get me thinking I should expand my optimizations beyond linear tweens, because you were right once I adjusted to also use “easeOutQuad” the performance difference wasn’t that different (although it still was waaaay better than iTween).
    I now have a new version of LeanTween that is optimized for “easeOutQuad”, “easeInQuad”, “easeInOutQuad” (I’ll extend this to other tween types if requested) . Once I put these optimizations in LeanTween was performing about 2x as fast as HOTween and without the framerate spikes.
    The new build is currently being approved by the Unity Store, but if anyone is eager to check it out you can download it from Google Code here. Also here are the files I used for testing the speed difference in case you see any mistakes (I enabled the overwritemananger but I didn’t notice a difference).

    [​IMG]
    The cpu profile of the different engines while tweening 1,500 boxes
    (This image doesn't quite capture how bad iTween worked compared to LeanTween and HOTween since it's spikes went all the way up to 700ms, while HOTween's spikes only went up to 65ms, and LeanTween doesn't have any noticeable spikes.)

    I just want to say HOTween seems like a very good tweening engine and I would certainly recommend it to others. The performance difference is probably not significant enough to make much of a difference, only when you may be tweening something ridiculous like 1,500 boxes. I think it really comes down to the style of programming that you prefer. HOTween looks to me more along the lines of Tweener, while I fashioned mine more like TweenLite.
    However I would not recommend iTween to any new Unity developers. Most everyone has mobile on the mind these days and the performance hit is really too substantial to ignore. Developing for mobile you have enough challenges to get optimal performance, the last thing you need to worry about is your tweening engine causing hiccups in the framerate.
     
    Last edited: Dec 13, 2012
  17. dsfds

    dsfds

    Joined:
    Aug 19, 2012
    Posts:
    16
    :( for unity4.0
     
  18. shaderbytes

    shaderbytes

    Joined:
    Nov 11, 2010
    Posts:
    846
    you need to disable it for speed test purposes as there is obviously some overhead in this management.


    Best wishes for your project , I'm personally a Hotween fan and have seen it grow in leaps and bounds via this community and Izitmees' excellent effort and collaboration on ideas/optimizations/features.
     
    Last edited: Dec 13, 2012
  19. dentedpixel

    dentedpixel

    Joined:
    Jul 15, 2012
    Posts:
    653
    Thanks Shaderbytes. I also tried disabling it: "HOTween.DisableOverwriteManager()", but I still haven't seen any difference...

    You can also download the code directly from the Google Code page.
     
    Last edited: Dec 13, 2012
  20. jeffweber

    jeffweber

    Joined:
    Dec 17, 2009
    Posts:
    435
    I tried using LeanTween. I get an "internal compiler error: Method not found: 'LeanTween.h'

    I only have a single test call:

    LeanTween.scale(this.gameObject,new Vector3(scaleAmount,scaleAmount,scaleAmount), pulseDuration);

    -Jeff
     
  21. dentedpixel

    dentedpixel

    Joined:
    Jul 15, 2012
    Posts:
    653
    Hi Jeff, this code should work. I tested it out. Make sure LeanTween.js is in your Plugins folder. For examples you can download this package here.
     
  22. dentedpixel

    dentedpixel

    Joined:
    Jul 15, 2012
    Posts:
    653
  23. I am da bawss

    I am da bawss

    Joined:
    Jun 2, 2011
    Posts:
    2,578
    Actually, after looking at the package now, I would like to vote for GUI Animation helper too! :)
    I think having a LeanTween Visual Editor and Inspector (much like HOTween Inspector where you can look at debug information) is a must, or it will just be too tedious.

    I also think "animate over a bezier curve" would be an essential feature, but not as essential as the GUI helper because without it - it would be like driving a car with no steering wheel and you must manually turn each wheel by hand! :D

    To be honest, I think all of the above should be included...but I would rate them in this order of priority :

    1. LeanTween Visual Editor and Inspector (GUI Animation helpers)
    2. Color Tweening (I think this one should be easy to implement and probably most essential in Tween engine)
    3. Looping (ping-pong, once, clamp forever) - also essential!
    4. Animate over a bezier curve (Would be very nice!)
    5. Some audio tweening function would be nice too (like iTween's Audio from and Audio to)
     
  24. jeffaaco

    jeffaaco

    Joined:
    Feb 21, 2013
    Posts:
    3
    Every time I compile I get "Cannot convert 'Boo.Lang.Hash' to 'System.Collections.Hashtable'. (BCE0022) (Assembly-UnityScript-firstpass)" on line 855, 880, 1092, 1172, 1253 and, 1283 of LeenTween.js. If it make a difference I'm using Unity 4.0.1f2 with MonoDevelop 2.8.2.
     
  25. dentedpixel

    dentedpixel

    Joined:
    Jul 15, 2012
    Posts:
    653
    Hi Jeff, that is strange, I am not getting any errors like that, and I am working with the exact same setup. Is this an error you get with a blank project as well? I am just trying to rule out if it's something else in your code that may be causing this issue... When in doubt it's often good to restart Unity if you haven't given that a try. I hope that helps...
     
  26. jeffaaco

    jeffaaco

    Joined:
    Feb 21, 2013
    Posts:
    3
    Yes, I'm also getting this error on a new project. I also tried starting a new project on my laptop with the same setup and got the same result.
     
  27. rahuxx

    rahuxx

    Joined:
    May 8, 2009
    Posts:
    490
    Playmaker support added? :)
     
  28. dentedpixel

    dentedpixel

    Joined:
    Jul 15, 2012
    Posts:
    653
    Hi Rahuxx, you know that's the second time that features has been requested. I am not familiar with Playmaker, but i will download it and check it out to see what would be involved in supporting it. Thanks for the suggestion.
     
  29. jeffaaco

    jeffaaco

    Joined:
    Feb 21, 2013
    Posts:
    3
    I got it to work by casting it to a Hashtable
     
  30. dentedpixel

    dentedpixel

    Joined:
    Jul 15, 2012
    Posts:
    653
    Hi Jeffaaco, I still don't see what the problem may have been. Could you private message me the change you made so that I can fix this for others? Was the change made in your code, or the LeanTween.js code?

    Thanks!
     
  31. Baskyn

    Baskyn

    Joined:
    Feb 17, 2013
    Posts:
    67
    Will you be adding things from iTween(punch, etc.) into LeanTween?

    Also, I got an error on line 855, 1253, 1172, 1092, 1283, and 880 of the LeanTween JavaScript. The error is, "Cannot Convert 'Boo.Lang.Hash' to 'System.Collections.Hashable'. (BCE0022)

    It looks like it's the same error as jeffaaco's.
     
    Last edited: Feb 27, 2013
  32. dentedpixel

    dentedpixel

    Joined:
    Jul 15, 2012
    Posts:
    653
    An update has been submitted that deals with the error that Jeffaaco and Baskyn were seeing.

    If you don't want to wait for it to be approved in the Asset Store you can always download the latest at Google Code:
    https://code.google.com/p/leantween/downloads/list

    Thanks @Jeffaaco for pointing out the fix for me! I wish I could replicate the error myself, but at least this will fix it for everyone who is seeing this error.
     
  33. dentedpixel

    dentedpixel

    Joined:
    Jul 15, 2012
    Posts:
    653
    Hi Baskyn, I am certainly up for adding new features, particularly when I see that they are useful and won't just cause bloat to the engine. I will look into the punch feature.

    Here is a forum page I started for offering suggestions for LeanTween, it's what inspired me to add the GUI helpers :)
     
  34. Baskyn

    Baskyn

    Joined:
    Feb 17, 2013
    Posts:
    67
    I'll take a look at the page!

    Thanks for the quick update! :)
     
  35. dentedpixel

    dentedpixel

    Joined:
    Jul 15, 2012
    Posts:
    653
    LeanTween is now offered in a C# variety! While LeanTween has supported C# for awhile now, developers who work in Visual Studio and compile their code to a DLL have not had access to it. For those developers who have this workflow this should no longer be a problem.

    Thank you so much @str1d3r at Modest Tree Media for porting it over for me!
     
  36. iddqd

    iddqd

    Joined:
    Apr 14, 2012
    Posts:
    239
    Many thanks for this library, it's very cool!

    In C# i see that it's currently not possible to have an onUpdate function that is not on a GameObject , we can only pass a function name which LeanTween then tries to call on the passed GameObject (which makes sense) or in my case the tweenEmpty GameObject, because I'm not passing a GameObject when calling the value function. Are you planning to add this feature?
     
  37. dentedpixel

    dentedpixel

    Joined:
    Jul 15, 2012
    Posts:
    653
    Not a problem iddqd! I am glad you are enjoying it. That should definitely be possible to add any function (not attached to a gameobject), it is at least possible for javascript. I am trying to look into the best way to pull off passing a function to be called in C#. Does anybody with more C# experience know the best way to do this? It looks like Actions may be the way to go...
     
  38. Izitmee

    Izitmee

    Joined:
    Jan 27, 2011
    Posts:
    3,215
    Actions are one way to go, but Unity supports only Action<T> and not Action or Action<T,T,etc> (or viceversa, I don't remember exactly :p), unless something changed in Unity 4. The easier way would be to create your own Action delegate, which is simply done like this:
    Code (csharp):
    1.  
    2. public delegate void LeanTweenAction<in T>(T p_newValue);
    3.  
    Otherwise, you could create an even simpler delegate if you don't have any parameters to pass to the callback function, like:
    Code (csharp):
    1.  
    2. public delegate void LeanTweenCallback();
    3.  
     
  39. iddqd

    iddqd

    Joined:
    Apr 14, 2012
    Posts:
    239
    Great, I'm looking forward to the delegates! :rolleyes:
     
  40. dentedpixel

    dentedpixel

    Joined:
    Jul 15, 2012
    Posts:
    653
    Thanks Izitmee! I considered making custom action types but then I decided it would be best to go another route, to maintain interoperability with both the C# and Javascript version.

    LeanTween now supports "onCompleteTarget" and "onUpdateTarget" in it's parameters, which allows you to target other game objects with a method if you choose to. It should be live on the Asset Store in the next day or two.

    Thanks Madgeniy for the idea, and Alex for giving me a head start on the development!
     
  41. iddqd

    iddqd

    Joined:
    Apr 14, 2012
    Posts:
    239
    very cool. Many thanks for the update!
     
  42. dentedpixel

    dentedpixel

    Joined:
    Jul 15, 2012
    Posts:
    653
    Hi Baskyn,
    In the upcoming update, punch is included, there is an example included in the Examples Zip.
     
  43. rocki

    rocki

    Joined:
    Aug 10, 2012
    Posts:
    1,256
    Hi, does LeanTween work on Flash ?
     
  44. dentedpixel

    dentedpixel

    Joined:
    Jul 15, 2012
    Posts:
    653
    Hi Rocki,
    That is a good question. I don't have access to building for Flash myself, I have been considering throwing down the extra $400 for that license, but I haven't been able to justify the cost yet. Anyone have experience using Leantween to build in Flash? I tried in the free preview in 3.5, but it was having some issues, but I have heard it's progressed quite a bit since then, so these may no longer be a problem...
     
  45. rocki

    rocki

    Joined:
    Aug 10, 2012
    Posts:
    1,256
  46. dentedpixel

    dentedpixel

    Joined:
    Jul 15, 2012
    Posts:
    653
    Thanks Rocki,
    Hmmm well let's just isolate the PunchExample and delete all the other example scripts. In ExamplePunch.js if you can change the line 21 to:

    LeanTween.rotateZ( gameObject, 320, 1.0, {"ease":LeanTweenType.punch, "onComplete":punchTest} as Hashtable);

    That should resolve the "Hash" error.
     
  47. rocki

    rocki

    Joined:
    Aug 10, 2012
    Posts:
    1,256
  48. dentedpixel

    dentedpixel

    Joined:
    Jul 15, 2012
    Posts:
    653
    Thanks Rocki, If you could send me over the converted Actionscript, I think it would be best to debug that. It's difficult to know what code it is referring to otherwise (since the line numbers are all off).

    Either respond to this thread or private message. Thanks again for your help.
     
  49. rocki

    rocki

    Joined:
    Aug 10, 2012
    Posts:
    1,256
  50. dentedpixel

    dentedpixel

    Joined:
    Jul 15, 2012
    Posts:
    653