Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    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. Hazneliel

    Hazneliel

    Joined:
    Nov 14, 2013
    Posts:
    305
    Anybody has experienced this problem? I still cannot resolve this issue.

    Code (CSharp):
    1.  
    2. foreach (int morphIndex in morphArray) {
    3.     LeanTween.value(gameObject, 0.0f, 10.0f, 0.3f).setOnUpdate((float value) => {                      
    4.         this.meshRenderer.SetBlendShapeWeight(morphIndex, value);
    5.     })
    6. }
    7.  
    Im doing a tween for each of my blendshapes, the problem is that it is not copying the block variables, instead they are passed by reference and it results in all the tweens tweening whatever reference is in morphIndex which in this case is the last element of the array.

    So cant we create Tweens with a for loop?

    I appreciate any help
     
  2. dentedpixel

    dentedpixel

    Joined:
    Jul 15, 2012
    Posts:
    683
    Hi there,
    You can pass values into the value method, you would do so in this way:


    Code (CSharp):
    1. for(int i = 0; i < groupGOs.Length; i++){
    2.  
    3. GameObject c2 = groupGOs[i];
    4.  
    5. LeanTween.value(gameObject, 0.0f, 10.0f, 0.3f).setOnUpdateParam(c2).setOnUpdateObject((float value, object obj) => {
    6. GameObject backGo = obj as GameObject;
    7. Debug.Log("backGo:"+backGo+"value:"+value);
    8. });
    9. }
     
  3. Hazneliel

    Hazneliel

    Joined:
    Nov 14, 2013
    Posts:
    305
    Nice, so setOnUpdateParam does the trick of copying the value to the block!
    Thank you!
     
    yuliyF and dentedpixel like this.
  4. SimteractiveDev

    SimteractiveDev

    Joined:
    Jul 9, 2014
    Posts:
    97
    Great, thanks for the quick fix!
     
  5. yuliyF

    yuliyF

    Joined:
    Nov 15, 2012
    Posts:
    194
    Can I backward a tween (I add LeanTweenVisual on item: 1 tween with difference params) ?
     
  6. Ironmuscle

    Ironmuscle

    Joined:
    Dec 4, 2016
    Posts:
    1
    Hey, I have a query.
    When I use Lean tween , when I try to add code using LeanTween.move i get errors as they say Lean tween is not found or something. The example projects don't work. What is the problem. I use Unity 5.4.3
     
  7. NFMynster

    NFMynster

    Joined:
    Jul 1, 2013
    Posts:
    69
    Are you sure that LeanTween is in your plugins folder?
     
    dentedpixel likes this.
  8. mrvv

    mrvv

    Joined:
    May 2, 2016
    Posts:
    5
    hi

    is there an option to use percentage instead of time ??? o_O
    Code (CSharp):
    1. LeanTween.move ( gameObject:GameObject  destination:Transform  time:float )
    0 moving the object to its start and 1 to move it to the end.
    and everything in between accordingly.

    i want to move an object back and forth on a spline . key-down move forward. key-up move back. :)
     
  9. dentedpixel

    dentedpixel

    Joined:
    Jul 15, 2012
    Posts:
    683
    You should look at the example scene: PathSplineTrackCS as it is doing just that, you might want to use the github version as I fixed a bug where if you went backwards too far it wouldn't wrap around to the end of the track: https://github.com/dentedpixel/LeanTween . I hope that helps!
     
  10. mrvv

    mrvv

    Joined:
    May 2, 2016
    Posts:
    5
    ohh crap the solution was so easy :confused:

    thanks for the reply i feel stupid now :rolleyes::D

    so in short just use
    Code (CSharp):
    1. ltPath.place( transform, 0.6f );
    very nice plugin btw !! and respect for your dedication to this support thread here, answering all those questions !!:)
     
  11. dentedpixel

    dentedpixel

    Joined:
    Jul 15, 2012
    Posts:
    683
    Great! I am glad that worked out :)
     
  12. frolicOne

    frolicOne

    Joined:
    Apr 21, 2015
    Posts:
    4
    Hi,

    I get these strange errors when an object with tween code is run during edit mode (from the inspector).
    It complains about DontDestroyOnLoad being called from the LeanTween Init function.

    Any idea about that?
     
  13. bitinn

    bitinn

    Joined:
    Aug 20, 2016
    Posts:
    961
    Thx for the nice module! Mind I ask 2 simple questions?

    - If I use the full source instead of DLL, is there any reasons to put LeanTween under Plugins? Seems like it would work just fine anywhere else?

    - While I can add it myself, do you plan to support a "yieldable" tween. It would be quite useful to write sequential-looking animation (sacrifice minimal performance for better code maintenance). For example, following (untested) code:

    Code (CSharp):
    1.     void Start () {
    2.         StartCoroutine(AnimationGroup(someObj, someFunction));
    3.     }
    4.  
    5.     IEnumerator AnimationGroup (GameObject obj, System.Action someFunction) {
    6.         yield return YieldableMoveX(obj, 200f, 1f);
    7.  
    8.         // this will be called only when above animation is done, and always before below animation
    9.         someFunction(obj);
    10.  
    11.         yield return YieldableMoveX(obj, 400f, 1f);
    12.     }
    13.  
    14.     IEnumerator YieldableMoveX (GameObject gameObject, float to, float time) {
    15.         int id = LeanTween.moveX(gameObject, to, time).id;
    16.         while (LeanTween.isTweening(id)) {
    17.             yield return null;
    18.         }
    19.     }
     
  14. dentedpixel

    dentedpixel

    Joined:
    Jul 15, 2012
    Posts:
    683
    Hi Flexwiz,
    For the moment LeanTween wasn't designed to be run in editor mode, there are a number of changes that would have to be made to make this work. I am sort of curious if it is possible, but for the moment that is not expected behavior.
     
  15. dentedpixel

    dentedpixel

    Joined:
    Jul 15, 2012
    Posts:
    683
    Hi there Bitinn,

    #1 - I still want to support those who do most of their programming in Unityscript, which is why I keep the files in the Plugins folder. I assume a good amount of people still use Unityscript? I know C# has become more and more popular, and much more of the standard, but I think it will be awhile (or never) before Unity drops all support for it.

    #2 - That's a very interesting idea. I have wanted to add sequencing as the next improvement to the engine, so this is definitely something to keep in mind for that... Thanks for the suggestion!
     
  16. bitinn

    bitinn

    Joined:
    Aug 20, 2016
    Posts:
    961
    > #1 - I still want to support those who do most of their programming in Unityscript

    Ah, thx, that explains it.

    > #2 - That's a very interesting idea.

    Glad you like it. This idea is quite popular in both C# and Javascript, so it's nice to have.

    =====

    If you don't mind, I have 2 small questions on chaining and attaching to game objects:

    - If I want to tween 2 properties on a GameObject at the same time (not sequentially, but in parallel), is the current best practice just to call LeanTween twice? Or is there chaining for multiple tweens as well? For example:

    Code (CSharp):
    1. // change both position and alpha, can we chain these two calls?
    2. LeanTweet.moveLocal(...);
    3. LeanTween.alpha(...);
    - If I want to tween a value, say a Vector3 or Float, is there a reason for why we still need to attach the tween to a GameObject? For example:

    Code (CSharp):
    1. // why is gameObject needed here? don't we have a global LeanTween object?
    2. LeanTween.value(gameObject, new Vector3(1f,0f,0f), new Vector3(5f,0f,0f), 5f).setOnUpdate(...)
    3. LeanTween.value(gameObject, updateValueExampleCallback, 180f, 270f, 1f)
     
  17. dentedpixel

    dentedpixel

    Joined:
    Jul 15, 2012
    Posts:
    683
    Not a problem,

    New #1
    - Yes, the current practice is just to call LeanTween twice

    New #2
    - This is done exclusively for the instances where you fire off a tween, but then load another level before it finishes. LeanTween checks to make sure the transform is around, before proceeding with anything.
     
    bitinn likes this.
  18. GrandahlD

    GrandahlD

    Joined:
    Jul 26, 2012
    Posts:
    3
    Loving LeanTween, but I'm having trouble with some basic functionality. I am trying to scale an object on Instantiate. I would like the tween to go from (0,0,0) to whatever it's normal scale is (like popping in to existence).

    I am hoping there is either a simple way to scale FROM a value, or an easy way to play a scale-to-0 tween in reverse.

    Any help is appreciated!
     
  19. dentedpixel

    dentedpixel

    Joined:
    Jul 15, 2012
    Posts:
    683
    Hi GrandahID,
    There is an undocumented feature, setFrom that you can use to accomplish this like:

    LeanTween.scale(cube,newVector3(1f,3f,0f),1.0f).setFrom(newVector3(5f,10f,3f));

    I didn't mean this to be an "undocumented feature" I will add it to the documentation for the next release. Thanks! Glad you are liking the engine so far :)
     
  20. dentedpixel

    dentedpixel

    Joined:
    Jul 15, 2012
    Posts:
    683
    Hi GrandahID,
    There is an undocumented feature, setFrom that you can use to accomplish this like:

    LeanTween.scale(cube,newVector3(1f,3f,0f),1.0f).setFrom(newVector3(5f,10f,3f));

    I didn't mean this to be an "undocumented feature" I will add it to the documentation for the next release. Thanks! Glad you are liking the engine so far :)
     
  21. CosmicGiant

    CosmicGiant

    Joined:
    Jul 22, 2014
    Posts:
    23
    Recommended method for checking if a specific animation or group of animations has finished?

    To add context, I'm making a breakout-like game (will be my first public-release game), in which I'm animating the blocks' fall/drop using LeanTween. I want the gamestate to be locked until all drop/fall animations are done, for example (there are other similar situations too, like with menus only accepting input after they are in place, or only actually resuming game when menu is fully gone, while still having other animations running).

    Right now I have already managed to make the block animations lock state, by putting them on a List<gameObject> when they start animating, and then removing them from it using the LeanTween's setOnComplete with the object itself as param, which I then remove from the list:

    Code (CSharp):
    1. LeanTween
    2.     .moveLocal(obj, board.GridToWorld(pos.x, pos.y - 1), brickDropTime)
    3.     .setEase(LeanTweenType.easeOutBounce)
    4.     .setOnStart(() => {
    5.         tweeningObjects.Add(obj);
    6.     })
    7.     .setOnCompleteParam(obj)
    8.     .setOnComplete((entity) => {
    9.         tweeningObjects.Remove(entity as GameObject);
    10.     });
    And then checking the list's count on the Update loop:

    Code (CSharp):
    1. protected override void OnUpdate() {
    2.     if (dropQueue.Count == 0 && tweeningObjects.Count == 0)
    3.         //Changing state here
    4. }
    It works fine (so far), but I'm not sure if LeanTween does it's tweenings in sequence and/or within the unity loop; if it doesn't, I'm a little bit afraid of a thread-race scenario doing this (one object getting added the same unlucky instant one is removed, and messing up the list's index or something, since AFAIK lists aren't thread-safe).

    I'd also like feedback from more experienced people: Is there a better way of doing this kind of state-locking?
     
    Last edited: Jan 5, 2017
  22. dentedpixel

    dentedpixel

    Joined:
    Jul 15, 2012
    Posts:
    683
    That seems like a reasonable way to do it. There is not any concept of groups of tweens that currently exists in LeanTween.

    I would suggest you could just keep an count iterator of the blocks and increment and decrement that variable because this would give you the same functionality without the extra overhead of keeping a list (it doesn't look like you are actually checking the list contents so you don't really need the actual list). You could then check if it is complete on every setOnComplete based on the integer count.

    LeanTween runs on the same Update loop as your game, so you should avoid any threading issues with it that way.
     
  23. CosmicGiant

    CosmicGiant

    Joined:
    Jul 22, 2014
    Posts:
    23
    Thanks for the reply dentedpixel!
    A counter was actually the way I was doing it first, but since I have multiple situations (in multiple gamestates) where I'll wait for animations to finish before moving to next state, and because my states are each on their separate classes, I plan to centralize the "state-locking animations" in the "game scene manager" somewhen not too far in the future.

    The game is fairly simple and the extra overhead from lists shouldn't be a problem even for release; I was far more worried about a thread-race scenario, but it seems my worry was unfounded.

    Thanks again for your awesome tweening engine! I <3 LeanTween!
     
    dentedpixel likes this.
  24. Marat_Gilyazov

    Marat_Gilyazov

    Joined:
    Feb 23, 2016
    Posts:
    5
    Hello,
    First of all - thanks for such great tween engine, it's very handy, lightweight and intuitive in most cases.

    The only thing I can't figure out - is there any simple way to finish the tween immediately instead of canceling it in the current condition?

    When you call "cancel" it stops the tween just where it was at the moment, but in many cases if I'm supposed to break the animation, I want fastforward it to the end, finish it. And the only option I see now - call "onComplete" and put some anonymous method finilizing the values, but doing it for every tween, especially when I'm tweening scale and position at the same time by some tricky pattern - seems very awkward.

    I saw few other tweeners (for unity and Flash) and such option was built in from the beginning, so I thought I just missed it in the docs.

    Is there any handy solution?

    Thanks!
     
  25. dentedpixel

    dentedpixel

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

    There is unfortunately not such an option :-/, but it does sound like a very useful feature. I am putting it in my notes of something to try and work in, in a future release. It's also up on github if you are feeling ambitious and want to attempt a solution yourself :)

    Thanks for the support! I am glad you are liking the engine
     
  26. liuxuan

    liuxuan

    Joined:
    Oct 13, 2014
    Posts:
    7
    Hi, I found when call setLoopPingPong will cause GC for every frame(unity: 5.5.1, LeanTween 2.44), is this a bug?
    Code (CSharp):
    1.  
    2. void Start () {
    3.      LeanTween.alpha (GetComponent<RectTransform>(), 0, 0.3f).setLoopPingPong (-1);
    4. }
     
    Last edited: Feb 8, 2017
  27. Marat_Gilyazov

    Marat_Gilyazov

    Joined:
    Feb 23, 2016
    Posts:
    5
    Thanks for the reply, looking forward for new releases.

    Yes, I already thought about tuning the source code and implementing such functionality. From first sight it should not be hard to dig into how actual "cancel" method works, add some bool flag as a parameter and just update tweened values to the final state. But at the moment I need to finish current game and will just use what I have, may be later.

    Good luck =)
     
  28. turkert

    turkert

    Joined:
    May 4, 2012
    Posts:
    18
    Hello,
    First of all thank you for great library. I've read half of the posts here from 2013 and you are absolutely stunning. I hope your works doing well for you.

    I've a problem about tweening but I am not sure whether it is directly related with LeanTween or not. So here is the situation:

    - Start button moves cross hair to target location and it comes back to original position on completion.
    - If I start another tween before it comes to original location cross hair misses the target by some margin. You may understand better on youtube. I may execute script multiple times successfully if it comes back to original location.

    Here is the relevant code:
    Code (CSharp):
    1.  
    2. void OnGUI()
    3. {
    4. if (GUI.Button(new Rect(10, 10, 50, 60), "Start"))
    5. {          
    6.     Vector3 v3NewTargetPos = new Vector3(Random.Range(-100, 100), -7.0f, 100.0f);
    7.     Debug.LogFormat("New Target Pos:{0}", v3NewTargetPos);
    8.     goTargetCurrent = Instantiate<GameObject>(goTargetPrefab, v3NewTargetPos, Quaternion.identity);
    9.  
    10.     Vector2 v2NextPos = FindNextPosition(goTargetCurrent, this.gameObject, this.cmrMain);
    11.  
    12.     if ((dCrossHairTweenId > 0) && (LeanTween.isTweening(dCrossHairTweenId)))
    13.     {
    14.         LeanTween.cancel(this.gameObject, dCrossHairTweenId);
    15.     }
    16.  
    17.     dCrossHairTweenId =
    18.         LeanTween
    19.         .moveLocalX(this.gameObject, v2NextPos.x, 1.0f).setSpeed(70.0f).setEase(LeanTweenType.easeSpring)
    20.         .setOnComplete(() => LeanTween.moveLocalX(this.gameObject, 0, 3.0f)).uniqueId;
    21. }
    22. }
    23.  
    24. Vector2 FindNextPosition(GameObject goTarget, GameObject goSource, Camera cmrMain)
    25. {
    26.     Vector2 result;
    27.     float flResultX, flResultY = 0.0f;
    28.  
    29.     //Find position on the screen space. Ekran duzeninde ki konumlari bulalim
    30.     Vector3 v3SourcePos = cmrMain.WorldToScreenPoint(goSource.transform.position);//TransformPoint(Vector3.one));
    31.     Vector3 v3TargetPos = cmrMain.WorldToScreenPoint(goTarget.transform.position);//TransformPoint(Vector3.one));
    32.  
    33.     //We will use x axis only for now. Once sadece X ekseninde hesap yapalim
    34.     if (v3SourcePos.x < v3TargetPos.x)
    35.     {
    36.         //If crosshair is going from left to right. Eger soldan saga dogru gitmemiz gerekirse
    37.         flResultX = (v3TargetPos.x - v3SourcePos.x) + 10.0f;
    38.     }
    39.     else
    40.     {
    41.         //If crosshair is going from right to left. Eger sagdan sola gitmemiz gerekli ise
    42.         flResultX = (v3TargetPos.x - v3SourcePos.x) - 10.0f;
    43.     }
    44.  
    45.     result = new Vector2(flResultX, flResultY);
    46.     Debug.LogFormat("Next Pos:{0}", result);
    47.     return result;
    48. }
    49.  
    Most probably I misunderstood something but I couldn't find so I need help.

    Thanks.
     
  29. turkert

    turkert

    Joined:
    May 4, 2012
    Posts:
    18
    I've investigated problem and most probably my calculations are wrong. It is not related to LeanTween.
     
  30. Osteel

    Osteel

    Joined:
    Jan 17, 2014
    Posts:
    59
    Hi @dentedpixel

    I'm currently working with the spline system and was wondering if you could clear some things up for me?

    1. Is there a way to not have there be any curve/smoothing between points? I'm currently building my spline by copying the start and end points for the control points, but it still does a slight curve. I would like to have very straight paths.

      Code (CSharp):
      1. swapPath = new LTSpline(new Vector3[] {startPoint, startPoint, startCorner, endCorner, endPoint, endPoint });

    2. Is there a way to move to a specific point over time? Currently I'm moving an object on the path based on the normalized position of the finger between two points. However, because it's using placeLocal each frame, if the player moves their finger very fast the object will of course move just as fast.


    3. Similar to the above point, is it possible to move to a specific point on the path from the object's current position on that path? The player moves the object on the path by moving their finger. However, if they release, I would like the object to move to either the beginning or end of the path based on some other unrelated conditions.


    4. Is there a way to determine the distance between the object and a given point? When moving the object, I would like to keep a constant speed (rather than time) regardless of how far away from the end the object is.

    Thank you!
     
  31. tarabout

    tarabout

    Joined:
    Jan 23, 2016
    Posts:
    11
    Hey @dentedpixel ,
    Not sure if this is the right place to ask about this or if there's some support email but I ve been getting over a 100 warning message since I updated leentween to the latest version. All the warnings are like " (name of LTDfunction) hides inherited number (name of LTDfunction) Use the new keyword if hiding is intented".
    Should I do some kind of clean uninstall and reinstall of the plugin or something?

    Thanks,
    Fred
     
  32. dentedpixel

    dentedpixel

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

    It sounds like you must have some duplicate files, and a clean install would be recommended. Just delete all files with LT or Lean in the name and you should be good to then re-import LeanTween.
     
  33. jlanisdev

    jlanisdev

    Joined:
    Jan 18, 2016
    Posts:
    76
    Is there a way to get the closest point on a path, based on a position nearby?
     
    laurentlavigne likes this.
  34. DutchRose-Jochem

    DutchRose-Jochem

    Joined:
    Mar 7, 2017
    Posts:
    2
    Hi @dentedpixel ,

    I'm trying to use alphaText to fade my text from 0 to 1.
    But it immediately goes to 1, no matter what value I use for the time.
    It seems to always just start at 1 and then fade from there, because if I change the 'to' value to 0.5f it first goes to 1 and then fades to 0.5.

    Thanks,

    Jochem
     
  35. username132323232

    username132323232

    Joined:
    Dec 9, 2014
    Posts:
    477
    It seems that .setUseEstimatedTime(true) makes no difference for a delay as in .setDelay(someDelayTime).

    So, the tween will not execute at all if the game is paused (Time.timeScale=0f). Is this correct and is there a quick workaround (other than using Invoke())? Thanks.
     
  36. ricecrispie60

    ricecrispie60

    Joined:
    May 6, 2014
    Posts:
    20
    @dentedpixel, Hullo sorry I've got to make a post about this.

    LT has suddenly just started spamming Index out of range exception error messages when calling LeanTween.isTweening(GameObj) & LeanTween.cancel(GameObj).

    I have added stupid amounts of null checks & nothing works because it is LT that is generating the error messages, there is nothing i can do about this without faffing around with your code.

    I have been using LT for over a year and it never did this while I was building all the stuff its being used for. Please Help this has thrown an enourmous spanner in the works of my project.

    Also where is the changelog for LT?
     
    Last edited: May 19, 2017
  37. JRRReynolds

    JRRReynolds

    Joined:
    Oct 29, 2014
    Posts:
    192
    @dentedpixel Thanks for bringing this tool to the community. I am actually in the process of porting over my code right now because of the improvement in performance. I had a question about Leantween vs ITween. In ITween, if I call the same tween it will overrwrite itself. Like iTween.MoveTo ... will stop a current moveto tween and move to the one most recently called. I was wondering if Leantween did this by default as well or if I should manually cancel the tween first then call the new one.

    I was also wondering if the ids for the tweens recycled themselves. So if you have an abnormally long gameplay session where tweens are created and destroyed let's say 1000 tweens are created every 5 minutes then destroyed 5 minutes later, at some point the ids won't run out.


    @ricecrispie60 What happens if right before you call LeanTween.cancel(GameObj), if you add the line Debug.Log (GameObj.name);
     
    Last edited: May 21, 2017
  38. ricecrispie60

    ricecrispie60

    Joined:
    May 6, 2014
    Posts:
    20
    @Zrexa I'll do what you say when I get time, but I think i'll just get the name of the object that .isTweening/.cancel is being called on (i can identify the culprits already - but i cannot identify why the exception is being thrown).
    Currently I've just stopped calling isTweening/.cancel and consequently(this might answer one of your questions) every so often i'm noticing some glitchy tweens as another (leantween.Value) is stacked on one currently running - but its better than the red exception message spam :)
     
  39. pep_dj

    pep_dj

    Joined:
    Nov 7, 2014
    Posts:
    179
    Hi @dentedpixel . Your plugin is really great, and I use it a lot. I would like to talk about these two issues:

    I've detected an issue, and I fixed it. Please, can you review my pull request?: https://github.com/dentedpixel/LeanTween/pull/113

    Also, I have a question. Let's say I execute LeanTwee.value(go, 0, 1, 1). When tween finishes, value is something like 0.99 instead of 1. Are you planning to fix it? Sometimes I have to assign onComplete method to set the final value, and it's so redundant.
     
    dentedpixel likes this.
  40. trx

    trx

    Joined:
    Aug 4, 2013
    Posts:
    8
    Hi @dentedpixel .
    I've some questions about some behaviors when checking an LTdescr if its null or not:

    1. I've noticed that if I get an tween via the LeanTween.descr(id) method, I get a NullReferenceException as long as LeanTween is not initialized, which has to be done manually, if i do not start a tween before. (tweens array is null)

    2. The documentation mentions that the tween returned by the LeanTween.descr(id) function should return null if the tween has finished, which does not seem to work. It looks like the tween will only be set to null if a new tween is created (with a new id). Is it better to use isTweening(id) in such a case? - FYI I have only tested this with the .alpha(canvasgroup) function yet.

    3. Both together give a strange behavior. Lets say I have to tweens a and b (both save their id separately). i save their ID on starting the tween and get their tween object with this id (LeanTween.descr(id)):
    1. When i start LeanTween and init() it myself. I get for both ID's a tween back.
    2. If I start the a tween, b will start returning null.
    3. if a is finished it remains a tween object.
    4. if b is started a changes to null.
    5. if b is finished it remains a tween object.

    thanks a lot :D
     
  41. dentedpixel

    dentedpixel

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

    You are right that is some unpredictable behavior. I located the code that was causing this and pushed an update. You shouldn't have to manually init it yourself and it should return null after it has completed tweening. It also shouldn't throw an error if you try and check it before it has started.

    https://github.com/dentedpixel/LeanTween/

    Thanks!
    Russ
     
  42. NFMynster

    NFMynster

    Joined:
    Jul 1, 2013
    Posts:
    69
    Hello! Is there a way to define a custom curve that the ease type should be? I see there is support for an animation curve, however, I'm unsure how to use it. My use case is that I have objects that should move x amount of distance on it's Y axis, so a curve to define how it should move would be awesome. Is this possible @dentedpixel ?
    EDIT: Typical right, you figure out the solution right after you post the question! Nevermind, I figured it out, using a animationCurve and MoveY method.
     
    Last edited: Aug 23, 2017
    dentedpixel likes this.
  43. NFMynster

    NFMynster

    Joined:
    Jul 1, 2013
    Posts:
    69
    How often is the Unity asset updated? I should be using the GitHub one, right?
     
  44. Eldirfar

    Eldirfar

    Joined:
    Feb 9, 2014
    Posts:
    65
    I have animation like

    LeanTween.scale(iconTransform, pickScale, animationTime / 6f).setLoopPingPong(3);

    Is it possible to cache animation in for eg in awake and play it later?
     
  45. Johannski

    Johannski

    Joined:
    Jan 25, 2014
    Posts:
    823
    Just a quick note for the sequencer. In the documentation and examples the initialization is like that:
    Code (CSharp):
    1. var seq = LeanTween.sequence();
    2. seq.append(1f); // delay everything one second
    3. ...
    I got a null reference exception for current at LTSeq Line 176 with that method. I dug around a bit and found out that it is also possible to use
    Code (CSharp):
    1. LTSeq sequence = LeanTween.sequence();
    which correctly sets the sequence now. I'm wondering why the tutorials are not using that method/if I'm missing something?

    Btw. great work on the asset, I really enjoy using it :)
     
  46. MrLucid72

    MrLucid72

    Joined:
    Jan 12, 2016
    Posts:
    962
    I'm having issues with screen space camera -- moveY() seems to shoot it REALLY far from it's destination. Any tips? I try to get my object from -130y to 0y. The expected result is to go to 0y (barely show on the screen). The actual result went to ~500 something y.
     
  47. John-B

    John-B

    Joined:
    Nov 14, 2009
    Posts:
    1,259
    Is it possible to animate camera properties, like FOV or Viewport Rect?
     
  48. larku

    larku

    Joined:
    Mar 14, 2013
    Posts:
    1,422

    Absolutely,

    Just use something like


    Code (csharp):
    1.  
    2. float from = 0;
    3. float to = 1;
    4. float overTime = 0.5f;
    5.  
    6. LeanTween.value(gameObject, (float v) =>
    7. {
    8.  //
    9.  // Use v to do funky stuff with FOV or Viewort
    10.  //
    11. }, from, to, overTime);
     
    dentedpixel likes this.
  49. John-B

    John-B

    Joined:
    Nov 14, 2009
    Posts:
    1,259
    Thanks. Viewport is a rect, and I don't see rect as an argument for value. I'd need four floats.
     
  50. larku

    larku

    Joined:
    Mar 14, 2013
    Posts:
    1,422
    Not 100% sure it'll do, but there's a Color version of the value method, Color should handle 4 values (hacky, but may do the job).