Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

General 2d tweening question

Discussion in 'Scripting' started by wkwan, Sep 14, 2014.

  1. wkwan

    wkwan

    Joined:
    Sep 14, 2014
    Posts:
    27
    I'm coming to Unity from simple 2D game engines like Corona SDK, where tweens are done by calling transition functions with some params. From what I've read, 2D tweening in Unity is done either with lerping or by using a 3rd party tweening engine. I'm curious to know, do devs usually choose between lerping/tweening engines just by preference or are there certain cases where one works better than the other?
     
  2. elmar1028

    elmar1028

    Joined:
    Nov 21, 2013
    Posts:
    2,353
    I use a free plugin called iTween! Its awesome and easy to use. Basically it adds tons of functions which allow you to do simple smooth movement, rotation and scaling.

    Try it out!
     
    Taschenschieber likes this.
  3. Taschenschieber

    Taschenschieber

    Joined:
    Jun 8, 2014
    Posts:
    238
    Seconded. iTween is a must have and handles many simple animation use cases way better than Unity's built-in animation system does. You can get it in the asset store.
     
  4. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,840
    Interesting — I never knew there was a need for something like that. Between Lerp, SmoothDamp, and good ol' fashioned math, it seems like you can accomplish any sort of "tweening" you might want with only a line or two of code.

    But this may be a case where I've been doing it a certain way for so long that I don't even realize there might be an easier way. I'll check out iTween just to see what I may have been missing!
     
  5. Taschenschieber

    Taschenschieber

    Joined:
    Jun 8, 2014
    Posts:
    238
    iTween is fire and forget, Lerp et cetera aren't, which will save you a couple of lines of code.
     
  6. wkwan

    wkwan

    Joined:
    Sep 14, 2014
    Posts:
    27
    So it seems like you just choose one or the other? I was just afraid that if I went with a tween engine i might be missing some commonly used functionality and have to end up having to combine it with lerping. But I'll check out this iTween, it seems more similar to what I'm used to.
     
  7. Taschenschieber

    Taschenschieber

    Joined:
    Jun 8, 2014
    Posts:
    238
    You can animate some things with iTween, others with Lerp and/or the Unity animation system. So, if you find that iTween can't handle a more complicated task, you can switch to another system for just this one task.
     
  8. orb

    orb

    Joined:
    Nov 24, 2010
    Posts:
    3,033
    The tweening tools available for Unity usually have some extra functions to make movement along curves simpler too.
     
  9. smitchell

    smitchell

    Joined:
    Mar 12, 2012
    Posts:
    702
    I personally switch between the two, And I don't use iTween; I use DOTween: http://dotween.demigiant.com (it's nicer to use, and is faster).

    For things like menu animations, small effects etc i'd use the tweening engine. Then actual gameplay things I'd use leaping, or my own tweening stuff
     
  10. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,840
    Thanks for pointing out DOTween. I had already made my own tweening/sequencing fire-and-forget classes, but DOTween looks like it may be even better!
     
  11. renman3000

    renman3000

    Joined:
    Nov 7, 2011
    Posts:
    6,680
    I use HOTween. Its the pre DOTween, DOTween. Its great. Very light, but super powerful.

    Cant wait for DOT to be ready.Will be using on any future projects.
     
  12. smitchell

    smitchell

    Joined:
    Mar 12, 2012
    Posts:
    702
    It really is amazing, I've created entire games that look like they've had months of development on in like a weekend with the help of DOTween :)