Search Unity

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. Greg-Bassett

    Greg-Bassett

    Joined:
    Jul 28, 2009
    Posts:
    628
    Got LeanTween visual yesterday from Asset Store and got things working exactly as I wanted in no time, great stuff!!!

    However, today LeanTween seems to have completely stopped working? I have re-imported LeanTween and LeanTween Visual in my project, but still nothing when I add a tween to an object.

    I installed LT and LTV into a new project and it works fine...

    Why would it stop working in my original project? anyone got any ideas? bit of a pain if I need to recreate my project in a new project? plus worried LT might stop working again...

    Thanks in advance!
     
  2. dentedpixel

    dentedpixel

    Joined:
    Jul 15, 2012
    Posts:
    683
    Shoot, I have never had that happen to me on any of my projects. There is no error or anything? The tween animations just decide not to work? I would right click on the plugins folder and choose "reimport" and maybe "reimport all" if that doesn't work. Or is that what you did already? I am not sure if just downloading the projects again from the asset store necessarily refreshes the installation...

    I am glad things were working well before this :), hopefully you can easily get it back to that state :-/
     
  3. Greg-Bassett

    Greg-Bassett

    Joined:
    Jul 28, 2009
    Posts:
    628
    Yep tried all that, nothing?

    It's crazy a scene in which I created a tween using the visual editor and which I cut and paste the code into a script works fine.

    But if I try and add a new tween object in the same scene, or even in a brand new scene with just a cube for instance, and add a visual tween and press Play I get nothing.

    Do any of the same in a new project and it works fine...

    I am going to recreate my scenes in a new project, hoping it doesn't happen again after I create the new project.

    I even updated Unity to the latest release.

    Weird and a shame, as I say I managed to get my tweens working brilliantly with the visual editor after having messed about with just code for a few hours with mixed results.

    Will keep you posted...
     
  4. Greg-Bassett

    Greg-Bassett

    Joined:
    Jul 28, 2009
    Posts:
    628
    Rebuilt the project and LeanTween is working again... :)
     
  5. dentedpixel

    dentedpixel

    Joined:
    Jul 15, 2012
    Posts:
    683
    Oh good! Not sure why the project singled out LeanTween :-/, but seems like something was messed up with Unity. I am glad that did the trick.
     
  6. cstlmode

    cstlmode

    Joined:
    Dec 2, 2014
    Posts:
    88
    Hello ,
    first i want to thank you for this great tweening engine ,
    so i've recently started using LeanTween , i'm curently converting all my itween code to LeanTween , i hope to not get stuck at something , i've looked up on the web some threads on leantween issues , i could not find that much , so either it's really perfect , or it's missing support ,
    hope it's the first one :D
     
  7. cstlmode

    cstlmode

    Joined:
    Dec 2, 2014
    Posts:
    88
    Hello Again ,
    well i'm having a little issue that i've been stuck with for a couple of hours , moveX is not behaving like it's supposed to , so what i'm trying to do is instancing a projectile on a cannon that rotates and looks to the player when it's moving , i passed the rotation and position variables to the clone instance projectile correctly , but it doesn't work ,
    ps i don't want to use move local , cause i don't want my projectile to rotate with cannon when it's following the player , i just want to have the first rotation data to shoot toward the player


    Code (JavaScript):
    1.      function Sendprojectile () {  
    2.        
    3.  
    4. // fx when projectile has been shoot
    5.         var  ProjectileOn_FXClone = Instantiate(ProjectileOn_FX,LensPos.transform.position,LensPos.transform.rotation);
    6.         Destroy(ProjectileOn_FXClone,3);
    7.         //projectile
    8.          var ProjectileClone = Instantiate(Projectile,LensPos.transform.position,LensPos.transform.rotation);
    9.  
    10.   LeanTween.move(ProjectileClone, new Vector3(0,-30,0), Speed) ;
    11.    
    12.         Destroy(ProjectileClone,5);
    13.  
    14.  
    15.     }
     
  8. dentedpixel

    dentedpixel

    Joined:
    Jul 15, 2012
    Posts:
    683
    Hi there, welcome to LeanTween!
    I think you need to use the TransformPoint method to convert the "new Vector3(0,-30,0)" to world space.

    That way you don't have to use moveLocal but can get a similar effect.
     
  9. cstlmode

    cstlmode

    Joined:
    Dec 2, 2014
    Posts:
    88
    Hello ,
    i found another solution for that projectile thing , it works great now , but i'm now in a need for moving some objects trought their local axis , i've tested pretty much all the move leantween and none of them work exacly like i wanted them to , so i tried the "TransformPoint" you mentioned it works now , but i'm not sure if i have done this the right way ,
    so here is my code , i was worndering if there is a much better was to do this , much clear and easy ,
    ps i used 'transform.up' cause i read somewhere that it's the same as using TransformPoint
    thank you for the help ,

    Code (JavaScript):
    1.  function Update  () {
    2. if(GoToTarget)   transform.position = Vector3.MoveTowards(transform.position,Player.transform.position, Time.deltaTime *Speed);
    3. }
    4. function TriggerThis () {
    5.  
    6.      LeanTween.value(this.gameObject ,0,2 , 1).setOnUpdate(UpdatePosition);
    7.      yield WaitForSeconds(1);
    8.      GoToTarget=true;
    9.      LeanTween.value(this.gameObject ,2,50,2).setOnUpdate( SpeedUpdate  );
    10. }
    11. function SpeedUpdate (NewValue:float ) {
    12.      Speed=NewValue;
    13. }
    14.      function UpdatePosition (NewValue:float ) {
    15.          //move toward local direction
    16.          transform.position += transform.up*0.05;
    17.      }
    18.  
     
  10. cstlmode

    cstlmode

    Joined:
    Dec 2, 2014
    Posts:
    88
    hello again ,
    i found a better way to do this , it's to use leanTween.value and trasform translate , which moves objects locally "didn't know that before ", the code now will be looking like this
    Code (JavaScript):
    1.  
    2.         function Sendprojectile () {  
    3.        
    4.          ProjectileClone = Instantiate(Projectile,LensPos.transform.position,LensPos.transform.rotation);
    5.  
    6. ProjectileClone.SetActive(true);
    7.  
    8. LeanTween.value(ProjectileClone,0,-30, Speed).setOnUpdate(UpdateDirection) ;
    9.  
    10.     }
    11.  
    12.         function UpdateDirection (NewValue :float) {  
    13.      
    14.             ProjectileClone.transform.Translate(NewValue,0, 0);
    15.         }
     
  11. JiuWei

    JiuWei

    Joined:
    Apr 13, 2015
    Posts:
    7
    Hello,
    LTDescr lt,ff;
    int id,fid;
    void Start () {
    lt = LeanTween.move(gameObject,100*Vector3.one,2);
    id = lt.id;
    LeanTween.pause(id);

    ff = LeanTween.move(gameObject,Vector3.zero,2);
    fid = ff.id;
    LeanTween.pause(fid);
    }
     
  12. JiuWei

    JiuWei

    Joined:
    Apr 13, 2015
    Posts:
    7
    void Update () {
    if(Input.GetKeyDown(KeyCode.A))
    {
    LeanTween.resume(id);
    }
    if(Input.GetKeyDown(KeyCode.D))
    {
    LeanTween.resume(fid);
    }
    }
    resume failed,I don't know why ,can you explain what happened,thanks,@dentedpixel
     
  13. dentedpixel

    dentedpixel

    Joined:
    Jul 15, 2012
    Posts:
    683
    That all looks correct to me. What happened exactly? The resume just never starts again? Could you share your project and I can test?
     
  14. JiuWei

    JiuWei

    Joined:
    Apr 13, 2015
    Posts:
    7
    public class Test : MonoBehaviour {
    LTDescr lt,ff;
    int id,fid;
    void Start () {
    lt = LeanTween.move(gameObject,100*Vector3.one,2);
    id = lt.id;
    LeanTween.pause(id);

    ff = LeanTween.move(gameObject,Vector3.zero,2);
    fid = ff.id;
    LeanTween.pause(fid);
    }

    void Update () {
    if(Input.GetKeyDown(KeyCode.A))
    {
    LeanTween.resume(id);
    }
    if(Input.GetKeyDown(KeyCode.D))
    {
    LeanTween.resume(fid);
    }
    }

    Thanks your reply.
    The above is the entire code,I init two LeanTween.move to a cube(pos(50,50,50)),and pause it in the Start function.Then in the update function ,when I press key A,it doesn't work, cube still at (50,50,50).
     
  15. dentedpixel

    dentedpixel

    Joined:
    Jul 15, 2012
    Posts:
    683
    Thank you for the reproduction code. I am looking into it, I am able to reproduce your problem so it looks to be a real bug that I will try and assess.
     
  16. woshihuo12

    woshihuo12

    Joined:
    Jul 18, 2014
    Posts:
    36
    hello dentedpixel, how can i rotate a RectTransform like a Image, rotate loop .........
     
  17. JiuWei

    JiuWei

    Joined:
    Apr 13, 2015
    Posts:
    7
    LeanTween.rotate(...).setLoopPingPong()?
     
  18. dentedpixel

    dentedpixel

    Joined:
    Jul 15, 2012
    Posts:
    683
    setLoopClamp() should be the right one. Check out the example scene GeneralUISpaceCS there is an example of rotating circles around the pause button. Hope that helps!
     
  19. ThinkertonGames

    ThinkertonGames

    Joined:
    Feb 26, 2015
    Posts:
    20
    Big fan on Leantween, great work! I did have one issue though, for some reason the first Leantween I do is ever so slightly choppy. It's just a Move, and every one after is smooth as silk. Any thoughts?
     
  20. woshihuo12

    woshihuo12

    Joined:
    Jul 18, 2014
    Posts:
    36
    i notice the example use setRepeat while not setLoopClamp....
    So what's the diff between setRepeat and setLoopClamp??
     
  21. _eternal

    _eternal

    Joined:
    Nov 25, 2014
    Posts:
    304
    How do I define the control points when creating a Vector3[] for the moveSpline() function?

    In the editor, my Lean Tween Path component shows a simple spline with four nodes. I'm trying to change the position of a couple of those nodes at runtime. However, I'm not getting the intended results by creating a new Vector3[] with just those four values, and I don't understand what control points the documentation is asking for (unlike for bezier curves, the spline curve didn't come with any control point objects in the editor).
     
  22. dentedpixel

    dentedpixel

    Joined:
    Jul 15, 2012
    Posts:
    683
    I am glad you are liking it :). I would make sure to add a LeanTween.init() on one of your awake methods. The first time performance probably has to do with some initializations that could be pre-empted by using this method.
     
  23. dentedpixel

    dentedpixel

    Joined:
    Jul 15, 2012
    Posts:
    683
    setRepeat by default sets it to setLoopClamp, setRepeat is for specifying how many times you want it to repeat, -1 for forever or a specific amount.
     
  24. dentedpixel

    dentedpixel

    Joined:
    Jul 15, 2012
    Posts:
    683
    This is from the documentation ( I know it's a little buried in there so I could see how you missed it!)

    path:Vector3[]
    A set of points that define the curve(s) ex: ControlStart,Pt1,Pt2,Pt3,.. ..ControlEnd
    Note: The first and last item just define the angle of the end points, they are not actually used in the spline path itself. If you do not care about the angle you can jus set the first two items and last two items as the same value.

    You will need to create 6 values, because the first and last point are just control points, and not points the curve will necessarilly pass through (just duplicate the first and last point if you do not care about the angle of the curve in the beginning or end).
     
    _eternal likes this.
  25. dentedpixel

    dentedpixel

    Joined:
    Jul 15, 2012
    Posts:
    683
    Hi Jiu,
    I have made an update on github that should fix this issue. Thanks for pointing it out! Let me know if you come across anything else...
     
  26. ThinkertonGames

    ThinkertonGames

    Joined:
    Feb 26, 2015
    Posts:
    20
    Thanks for the tip, I'll give it a whirl later and get back to you.
     
  27. woshihuo12

    woshihuo12

    Joined:
    Jul 18, 2014
    Posts:
    36
  28. dentedpixel

    dentedpixel

    Joined:
    Jul 15, 2012
    Posts:
    683
    Sorry I hadn't pushed the files correctly, I have now pushed that fix to github if you want to try and check again...
     
  29. dentedpixel

    dentedpixel

    Joined:
    Jul 15, 2012
    Posts:
    683
  30. JiuWei

    JiuWei

    Joined:
    Apr 13, 2015
    Posts:
    7
    Hello,dentedpixel.
    LTDescr descr = LeanTween.moveX(...);
    When it complete,does the descr destroy itself?
    I found the descr is not null after it complete,how can i restart(not resume) the descr?
    if not destroyed ,the more LeanTween.moveX(...) ,the more memory increased?
     
  31. dentedpixel

    dentedpixel

    Joined:
    Jul 15, 2012
    Posts:
    683
    LeanTween was designed to not get hit by the garbage collection penalty (whenever possible). So when LeanTween.init() is called, or the first thing tweened all the collections of LTDescr are allocated in memory and recycled after every tween (so that LTDescr will be used for a new tween later down the road).

    There is no way to restart a LTDescr, just call your original method again...
     
  32. Kmess

    Kmess

    Joined:
    Dec 21, 2013
    Posts:
    11
    I'm seeing an issue where LeanTween is using the same uniqueIDs for different LeanTweens.

    On instantiating a gameobject, I have a script that moves it in like so
    - LeanTween.move(gameObject,newVector3(-.209f,-3.891f,-01.162f),2.0f).setEase(LeanTweenType.easeInQuart)

    However, on a GUI class shortly after I setup an animation like so:
    - LeanTween.rotate(ringAninimationRects[index],360f,remainingDuration);

    The 2nd LeanTween has the same uniqueId as the first one. I try to cancel the GUI LeanTween but it also cancels the initial LeanTween due to them sharing the same uniqueIDs.

    As a workaround, I am able do a setID on the first LeanTween to a random uint. After implementing this, I'm unable to see the issue of both of them cancelling out.

    Is this a known issue or am I setting up the LeanTweens incorrectly?
     
  33. dentedpixel

    dentedpixel

    Joined:
    Jul 15, 2012
    Posts:
    683
    Hi there, I wasn't aware of this problem. Do you have any good reproduction steps? Or if you could share your project or a simplified version of the scenario, that would be super helpful.

    If you want to check out the scene TestingIssue on github, I tried a simple recreation there, but without any luck.

    Thanks!
    Russ
     
  34. Tony707

    Tony707

    Joined:
    Jun 15, 2015
    Posts:
    38
    Hi dentedpixel,

    Congrats for the hard work on this tween library, it works well!

    I'd like to know if there is any way I can use a LT.move with script path following, eg without any curve ?
    This would act as the move_transform action but with multiple waypoints.

    Thank you.
     
  35. cstlmode

    cstlmode

    Joined:
    Dec 2, 2014
    Posts:
    88
    Hello Dentedpixel , is there a way to do something like this , in order to get a more dynamic scipte that i can use on other paths ,
    thank you ,
    Code (JavaScript):
    1.   var Path:Transform [];
    2. function FollowPath(){
    3. LeanTween.moveSpline(Player, Path[].position,2).setEase(LeanTweenType.easeOutQuad).setOrientToPath(true);}
     
  36. dentedpixel

    dentedpixel

    Joined:
    Jul 15, 2012
    Posts:
    683
    Hi Tony707,

    Thanks a bunch! I am glad you are liking the library :)

    There isn't a built-in method that does what you are proposing but you can use LeanTween.value to accomplish it without too much difficulty. I code up an example in GeneralAdvancedTechniques scene, you can find it on github.

    Cheers,
    Russ
     
    Tony707 likes this.
  37. dentedpixel

    dentedpixel

    Joined:
    Jul 15, 2012
    Posts:
    683
    Hey CstlMode, I am not quite sure what you were asking for. Could you clarify?

    Thanks!
    Russ
     
  38. cstlmode

    cstlmode

    Joined:
    Dec 2, 2014
    Posts:
    88
    Hello Russ ,

    instead of defining the transforms manually in the LeanTween.moveSpline script ,i want to put them in an array , so i can modify the array only without having to modify the script
    is there a way to do this ?

    thanx a lot
     
  39. dentedpixel

    dentedpixel

    Joined:
    Jul 15, 2012
    Posts:
    683
    If you are passing an LTSpline object, to the moveSpline method, you should be able to overwrite that LTSpline reference and it should in theory update. like:

    spline = new LTSpline( Path[].position );

    I didn't test it though, so let me know if that doesn't work :)
     
  40. Pho3nix

    Pho3nix

    Joined:
    Dec 10, 2015
    Posts:
    3
    Hi!

    I have just started using your asset and it's amazing!

    One thing I don't get is how i get access to ratioatpoint?
    http://dentedpixel.com/LeanTweenDocumentation/classes/LTSpline.html#method_ratioAtPoint

    For example, my understanding is that if i have a vector3 array named raay, i can just do this:

    LTSpline cr = new LTSpline(raay);

    Debug.Log(cr.ratioAtPoint(raay[2]));
    (If I want to know how far point two is on a scale from 0-1)

    But I don't get that option, the method does even not show up in VS.
    (Instead: 'LTSpline' does not contain a definition for 'ratioatpoint')

    Have I missunderstod how to use ratioatpoint?
     
  41. dentedpixel

    dentedpixel

    Joined:
    Jul 15, 2012
    Posts:
    683
    Thanks Pho3nix!

    I think you just have the capitalization wrong, try:

    cr.ratioAtPoint
     
  42. Pho3nix

    Pho3nix

    Joined:
    Dec 10, 2015
    Posts:
    3
    Hmm, this is what I have available to me:
    upload_2016-6-13_16-48-23.png
     
  43. _watcher_

    _watcher_

    Joined:
    Nov 7, 2014
    Posts:
    261
    Hi! Need help rotating a circle infinitely. The circle is UI Image, rotation.z is 0.

    When using this code, it doesnt rotate at all:
    LeanTween.rotateZ(goRotatingCircle, 360f, 1f).setLoopClamp(-1);

    When using this code, it rotates once:
    LeanTween.rotateZ(goRotatingCircle, -720f, 1f).setLoopClamp(-1);

    When using this code, it rotates once:
    LeanTween.rotateZ(goRotatingCircle, -720f, 1f).setLoopClamp(10);

    Is there currently an issue with setLoopClamp? Am i missing something?
     
  44. _watcher_

    _watcher_

    Joined:
    Nov 7, 2014
    Posts:
    261
    Other things i noticed:
    1)
    LeanTween.textColor
    LeanTween.colorText
    ^ duplicity? backward compatibility?

    2)
    Need way to tween UI Image color. Atm only have LeanTween.textColor (for text), LeanTween.color (for material). Need LeanTween.ImageColor/RawImageColor. Whats best way to approach this atm? LeanTween.value?
     
  45. dentedpixel

    dentedpixel

    Joined:
    Jul 15, 2012
    Posts:
    683
    Hi _watcher_,
    You want to use the rotateAround method in almost all scenarios where you want precise control, you should be able to do it like:
    LeanTween.rotateAroundLocal(goRotatingCircle, Vector3.forward, 360f, 12f).setRepeat(-1);
    Check out the GeneralUISpaceCS scene to see it in action.
     
  46. dentedpixel

    dentedpixel

    Joined:
    Jul 15, 2012
    Posts:
    683
    #1 - Hehe yeah, that is just leftover backwards compatibility code, I prefer the colorText naming, so that's what is in the documentation but I don't want to break any old code.
    You should be able to have it tween the ui image color, just pass it the RectTransform when calling LeanTween.color( rectTrans, Color.red, 1f)
     
  47. dentedpixel

    dentedpixel

    Joined:
    Jul 15, 2012
    Posts:
    683
    Hmmm, I am not sure why it is not coming up in autocomplete, it should be there. Does it not work if you just type it in manually?
     
  48. _watcher_

    _watcher_

    Joined:
    Nov 7, 2014
    Posts:
    261
    rotateAroundLocal - works perfectly, thanks! and sorry i shouldve checked the examples first!
     
  49. _watcher_

    _watcher_

    Joined:
    Nov 7, 2014
    Posts:
    261
    This works perfectly, thank you!
     
    dentedpixel likes this.
  50. Pho3nix

    Pho3nix

    Joined:
    Dec 10, 2015
    Posts:
    3
    Nope, sorry, it just gives the same error as before, LTSpline does not contain a definition for 'ratioAtPoint' :(