Search Unity

DOTween (HOTween v2), a Unity tween engine

Discussion in 'Assets and Asset Store' started by Demigiant, Aug 5, 2014.

  1. Raimis

    Raimis

    Joined:
    Aug 27, 2014
    Posts:
    160
    Thanks for prompt reply. It seems that yesterday DO didn't set up properly. Today I can see all the properties I didn't see yesterday. (Or maybe that version had some errors in it). Doesn't matter. We are now looking for a tweening solution to work nicely with new gui. I will give yours a try and I hope we will use it in our projects from now on. Not a big fan of native animations when it comes to animating GUI.

    One suggestion - Can you please only initialize new DOTween if one is not available in hierarchy? Right now, since we execute a lot of code in Edit mode, I have to wrap all DO code with Application.isPlaying if statement. Otherwise [DOTween] objects are created in editor and these never get deleted. Each time I run and stop app I get at least one instance that has to be deleted manually.
     
    Last edited: Oct 8, 2014
  2. pixelballoon

    pixelballoon

    Joined:
    Mar 5, 2013
    Posts:
    11
    @Izitmee I've just tried out the new functionality and it seems to work well from some quick tests, fantastic work, thanks!
     
  3. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    @pixelballoon Great! Gonna publish it officially tomorrow!

    @Raimis Tomorrow I'll add checks to prevent the DOTween object to be created by editor scripts and publish a new update. In the meantime you don't need to wrap your code within Application.isPlaying, because since the last version (0.9.130) if DOTween finds an already existing DOTween gameObject carried on by the editor it deletes it at runtime (I added this check for what I thought was a bug caused by a Unity crash, didn't realize you might be calling tweens in Edit mode).
     
    pixelballoon likes this.
  4. Nemial

    Nemial

    Joined:
    Feb 25, 2014
    Posts:
    16
    @Izitmee Thank for the Join() function makes it so much nicer to chain a sequence together now without what appears to be magic numbers bursting out at the seams, and thanks for clearing up the Explanation of how a sequence works.

    So is there the possibility of being able to edit a sequence and tweens pertaining to a sequence after running it? because from my last post as i was showing i wanted to play some of the tweens i did but in reverse to effectively undo them, however it crashed when i attempted to do so, and the solution is to create another tween undoing what you did.

    so something like
    Code (CSharp):
    1.  
    2. Tweener firstTween = transform.DOMoveX(45, 1);
    3. Tweener secondTween = transform.DORotate(new Vector3(0,180,0), 1);
    4.  
    5. DOTween.Sequence()
    6.   .Append(firstTween)
    7.   .Append(secondTween);
    8.  
    9. //Bunch of stuff happens
    10.  
    11. firstTween.PlayBackWards();
    12.  
    instead of
    Code (CSharp):
    1.  
    2. Vector3 previousPosition = transform.localPosition;
    3. Tweener firstTween = transform.DOMoveX(45, 1);
    4. Tweener secondTween = transform.DORotate(new Vector3(0,180,0), 1);
    5.  
    6. DOTween.Sequence()
    7.   .Append(firstTween)
    8.   .Append(secondTween);
    9.  
    10. //Bunch of stuff happens
    11.  
    12. transform.DOMoveX(previousPosition.x, 1).Play();
    13.  
    It's not as if this feature is vital to this libraries efficacy as a tween engine, however in my personal opinion the first example feels better and more intuitive then the second example.

    I am currently using unity test tools for some of my tests and in one or two cases i have had to do something like the following to make sure the tests pass since they logic has to be fired in one pass through.

    Code (CSharp):
    1.  
    2. if(!Application.isPlaying)
    3. {
    4.     //If a trap exists spring it and let it handle the cards attacking otherwise just attack as normal.
    5.     if( gridExtension.doesSpringTrapDelegate != null )
    6.     {
    7.         _battleCardNominated.SpringTrap(ref gridExtension.doesSpringTrapDelegate);
    8.     }
    9.     else
    10.     {
    11.         ConfirmedCardAttack();
    12.     }
    13. }
    14. else
    15. {
    16.     cardDropTween.OnComplete(()=>
    17.     {
    18.         battleCardNominated.transform.DOScale( new Vector3(1,1,1),0.3f).OnComplete(()=>
    19. {
    20.             //If a trap exists spring it and let it handle the cards attacking otherwise just attack as normal.
    21.             if( gridExtension.doesSpringTrapDelegate != null )
    22.             {
    23.                 _battleCardNominated.SpringTrap(ref gridExtension.doesSpringTrapDelegate);
    24.             }
    25.             else
    26.             {
    27.                 ConfirmedCardAttack();
    28.             }
    29.         });
    30.     });
    31. }
    32.  
    there are also some instances where my tests run some tweens and i end up with a [DOTween] in my scene which i have to manually delete. I see you mentioned something about the next update addressing these things?
     
  5. YaVeTaL

    YaVeTaL

    Joined:
    Sep 25, 2014
    Posts:
    29
    Exactly, that was my basic question: how to pass a refs to cached sequences :) Seems it is not possible, but i'll check those methods.

    PS: solved for now by creating a new tween, but it would be cool to be able to modify sequence dynamically.
     
    Last edited: Oct 9, 2014
  6. YaVeTaL

    YaVeTaL

    Joined:
    Sep 25, 2014
    Posts:
    29
    Just another question: is it possible to scale item up "elastically" ?
    Kinda current scale is .5, i want it to jump to .75, but with "extra movements", so item will scale up to .8, then - to .7, and then will end up at .75.

    Something like DoScale(), not linear, but "elastic_in".
     
    Last edited: Oct 9, 2014
  7. YaVeTaL

    YaVeTaL

    Joined:
    Sep 25, 2014
    Posts:
    29
    .. and it would be nice to have in documentation an animation sample for DoShakeScale() as DoPunchScale() has.
     
  8. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    @Nemial Once a tween is inserted in a Sequence you cannot control it anymore: allowing the contrary would create a true mess, both logic wise and code wise, sorry :p That said, it worries me that you say it crashed when you tried it: I'll add additional checks to prevent that.

    About the persistent DOTween instance, within today I should release an update that fixes that.

    @YaVeTaL Now way to pass refs as end values, and I don't plan to implement it because it would be overkill for a tween engine :p
    About the elasticity of a tween, you can either use an Ease.OutElastic ease, or a custom made AnimationCurve.
    About the example, will do: as soon as I release the next update I'll add it.
     
  9. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    NEW UPDATE 0.9.180
    • NEW: Added overload to Shake methods that allows to choose how much to shake on each axis
    • CHANGE: Moved DOTween Setup menu item inside Tools menu (so it can share it with other plugins)
    • BUGFIX: Fixed DOTween Component being created while in Edit mode
    • BUGFIX: Prevented any play operation to throw errors with nested tweens
    • BUGFIX: Fixed Ease.InExpo not calculating values correctly
    • BUGFIX: Fixed DOTween Setup displaying warnings when it ends, and showing the end dialog twice on Unity 4.2 or older
    • Added animated gifs on Transform DOShake methods inside website documentation
    IMPORTANT: The DOTween Setup menu item is now inside the Tools menu, so other plugins can share it.

    dotween_setup.png


    @YaVeTaL Animation samples added :)
    @Nemial This update fixes the DOTween component being created in Edit mode. Also fixes errors being thrown if you try to Play/Rewind/etc a nested tween (it still won't work though).
     
  10. MrEsquire

    MrEsquire

    Joined:
    Nov 5, 2013
    Posts:
    2,712
    I recently updated my tween version and now I get the following messages, not sure if related to my code:

    Code (CSharp):
    1. ArgumentOutOfRangeException: Argument is out of range.
    2. Parameter name: index
    3. System.Collections.Generic.List`1[Waypoint].get_Item (Int32 index) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.Collections.Generic/List.cs:633)
    4.  
    5. IndexOutOfRangeException: Array index is out of range.
    6. DG.Tweening.Core.TweenManager.RemoveActiveTween (DG.Tweening.Tween t) (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__DOTween.Assembly/DOTween/Core/TweenManager.cs:684)
    7. DG.Tweening.Core.TweenManager.Update (UpdateType updateType, Single deltaTime, Single independentTime) (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__DOTween.Assembly/DOTween/Core/TweenManager.cs:378)
    8. DG.Tweening.Core.DOTweenComponent.Update () (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__DOTween.Assembly/DOTween/Core/DOTweenComponent.cs:49)
    9.  
    10. IndexOutOfRangeException: Array index is out of range.
    11. (wrapper stelemref) object:stelemref (object,intptr,object)
    12. DG.Tweening.Core.TweenManager.ReorganizeActiveTweens () (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__DOTween.Assembly/DOTween/Core/TweenManager.cs:662)
    13. DG.Tweening.Core.TweenManager.Update (UpdateType updateType, Single deltaTime, Single independentTime) (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__DOTween.Assembly/DOTween/Core/TweenManager.cs:313)
    14. DG.Tweening.Core.DOTweenComponent.Update () (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__DOTween.Assembly/DOTween/Core/DOTweenComponent.cs:49)
    15.  
    Any ideas?

    EDIT: Just saw you posted: UPDATE 0.9.180
    Updated to this, error message is gone above, but still please check it.
    This time the behavior of my game not as expected, will need to revert to older version if a issue still.
     
    Last edited: Oct 9, 2014
  11. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    @MrEsquire That original error seems to be related to an old bug I fixed a while ago. What version were you using? Also, what you mean that the behaviour of your game is not as expected with the new update? Can you tell me more so I can check it out?
     
  12. MrEsquire

    MrEsquire

    Joined:
    Nov 5, 2013
    Posts:
    2,712
    Hi sir, I cant remember the exact version for sure, you do many updates and I update the package every so often. I think it was DOTween v0.9.130 (October 5, 2014) I can tell you for sure if there is a quick way to tell?
    I have now upgraded to v0.9.180 and the error does seem to have gone.

    The version v0.8.530 (September 20, 2014) worked perfectly for me in terms of game play. The code I written did what is suppose to do, I will now need to debug the code to see if I messed up some place with current builds. But with version v0.9.130 the expected behavior of the characters movement has some how changed, no error messages are present this time, so hard for me to tell.

    Using Unity 4.6 Beta 20 and did the additional install from menu as instructed.

    I will provide more information tomorrow
     
  13. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    Thank you for the info :) To check what version of DOTween you're using you can simply select the [DOTween] gameObject while playing: the Inspector will show you the version among other things (there's also a "check latest update" button).

    I think I might know what is your issue. Maybe the tweens are running slower now? Version 0.8.530 had a bug that I just recently solved. Sometimes, either when you created a tween while in Edit mode or if Unity crashed for some reason, the [DOTween] Component was leftover in the scene, which meant that when the scene started there were two tween managers updating everything and thus animations ran at twice the speed.
     
  14. agamedesigner

    agamedesigner

    Joined:
    Jul 21, 2012
    Posts:
    19
    Hi, first of all, awesome library. I'm currently using it in my project and it's going great—sequences are awesome!

    I have a question though—I have version 0.9.030 (just realized there are updates since then) and I was wondering what the difference between SetAutoKill and SetRecyclable is.

    I'm guessing that disabling autokill lets me keep that exact tween without it getting killed (of course), and recycling will recycle (send into a pool) the tween container for use the next time a new tween is created somewhere?
     
  15. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    Hi @agamedesigner, glad you like it!

    I'll have to add this question to the FAQ, because you're the second person asking and I realize it's not clear. In short you got it right though. If you want to replay (or rewind or stuff like that) the exact same tween which you stored as a reference, you want to prevent it to be killed the first time it completes, so that's what SetAutoKill is for.
    Recyclable comes in play when a tween is killed. If it's off, the tween is completely destroyed. If it's on, the tween is just reset and put in a pool, then recycled when creating another tween.
     
  16. agamedesigner

    agamedesigner

    Joined:
    Jul 21, 2012
    Posts:
    19
    Thanks for the confirmation! Hope I can send some 'support' your way when I am less broke!
     
  17. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    Let's just hope we'll all be less broke soon enough ;)
     
  18. agamedesigner

    agamedesigner

    Joined:
    Jul 21, 2012
    Posts:
    19
  19. YaVeTaL

    YaVeTaL

    Joined:
    Sep 25, 2014
    Posts:
    29
    Yay, thanks for animation - that is very handy :)
     
  20. MrEsquire

    MrEsquire

    Joined:
    Nov 5, 2013
    Posts:
    2,712
    Thanks for the information, I do remember this bug and indeed it seems to be solved.
    I think this time it was my issue, I edited some of my code and updated to the latest version and I think everything is ok now, apologies for the false alarm.

    One other question, when using the Tween Engine for game on iOS platform, how is it best to debug in terms of CPU usage. Currently in iOS I have something called "Overhead" causing me lot CPU usage. I know this not probably related to the tween engine at all as I see (DOTweenComponent.Update()) etc but any comments would be most useful?

    Thanks
     
  21. MikeTon

    MikeTon

    Joined:
    Jan 10, 2013
    Posts:
    57
    Hey Izitmee, really digging DOTween, and love working with it so far. And I was really happy to sponsor your efforts here!

    I was hoping maybe you can give me a pointer on tweening a float property on materials:

    Here is what I have so far (I''m not familiar with lambdas in C#):

    DOTween.To(()=> efxMat.GetFloat("_echoMix"), x=> efxMat.SetFloat("_echoMix", x)=x, 1.3, 1);

    (This is a material from the CORE Shader Framework : https://www.assetstore.unity3d.com/en/#!/content/5447 And while the framework does come with it's own homebrew Tweener, I rather use DOTween to decrease the mental load for my project ).

    Also here are what I'm reading to be the EasyTweens available for materials:
    DOColor(Color to, float duration)
    DOColor(Color to, string property, float duration)
    DOFade(float to, float duration)
    DOFloat(float to, string property float duration) //<----I'd like to put in a request for something like this???

    Anyhows, thanks for your attention, time and consideration.

    -Mike
     
  22. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    NEW UPDATE 0.9.190

    @MikeTon Hey Mike, once again thanks a lot for your support (and I apologize again for the "ton" pun in my thank you mail, but I really couldn't resist in spite of the banality of it)!
    To achieve what you were doing with lambdas, you should've written this (only the "=x" was wrong, since you're calling a straight method in case of properties instead than simply assigning a value to a variable):
    Code (csharp):
    1. DOTween.To(()=> efxMat.GetFloat("_echoMix"), x=> efxMat.SetFloat("_echoMix", x), 1.3, 1);
    That said, you don't need it anymore because the new update adds DOFloat as you asked (and also DOVector, since I thought that might be handy too) :)

    @MrEsquire I'm very sure "overhead" has nothing to do with DOTween, but for the rest I'm not sure of what you're asking. In what ways you would want to debug DOTween?
     
  23. MikeTon

    MikeTon

    Joined:
    Jan 10, 2013
    Posts:
    57
    Thank you thank you buddy! That was fast, and I appreciate your sense of humor:) . I am sure that you are a blast to work with!

    -Mike Ton



     
  24. Seith

    Seith

    Joined:
    Nov 3, 2012
    Posts:
    755
    Hi Izitmee, sorry to report bad news but I've upgraded to the latest version and I still have situations where the DOTween object is not destroyed when getting out of game mode (and as a consequence causing the dreaded double-speed):

     
  25. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    Agh!!!! Thanks to your log I managed to replicate it though. This time it's caused by a different thing: you apparently have a tween that is created when one of your components is destroyed, and since stopping the player counts as a destroy, that error happens. I'm on it! Hope to post an update within one hour, but if not I'll have to run out and will post it in the afternoon. Will surely solve it today though.
     
  26. Seith

    Seith

    Joined:
    Nov 3, 2012
    Posts:
    755
    Cool, I'm glad that helped you to pinpoint the issue! :)
     
  27. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    NEW UPDATE 0.9.195 (merged with previous update 0.9.190)
    • BUGFIX: Fixed DOTween Component being left over if a tween is created while the application is quitting

    @Seith Voilà :) A note though, in case of a very rare use case. If the very first tween in your project is created only when the application is quitting, that error will still happen unless you initialized DOTween. If that's your use case, just be sure you call DOTween.Init when your project starts (so the DOTween component is created and it can use OnApplicationQuit to determine when the app is quitting - which is sadly the only way to determine that) instead than relying on it being called automatically. You can just call it without any parameter to have it set up the same way as it was set up automatically.
     
  28. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    @MikeTon Ah! Thank you for giving me a pass for the ton joke :)
     
  29. Seith

    Seith

    Joined:
    Nov 3, 2012
    Posts:
    755
    Formidable! :) Thank you very much! I'll do like you suggest and call DOTween.Init in my game manager when the game starts, so hopefully that will take care of all the cases.
     
  30. Nemial

    Nemial

    Joined:
    Feb 25, 2014
    Posts:
    16
    Another question. You have made it clear that a tween is much like a movie clip in that it cant be edited after creation and playing however i was wondering if this idea i have in mind is particularly feasible. say i have an object moving around and i want another object to tween to it at a particularly slow rate, however once the tween is complete it will be in the objects wake rather than actively moving towards it. So to achieve a sort of tracking effect via Tweens would require you to constantly create new Tweens on the object in an update function quite possibly killing the old ones to stop any conflicting tweens(i am not certain what the effect of having two separate Tweens that affect the same property play over each other will have).

    for example

    Code (CSharp):
    1.  
    2. float TweenDuration = 0.5f;
    3. float AccumulatedTime = 0;
    4. void Update()
    5. {
    6.     AccumulatedTime += Time.deltaTime;
    7.     if(AccumulatedTime > TweenDuration)
    8.     {
    9.         AccumulatedTime = 0;
    10.         displayCopy.transform.DOKill();
    11.         displayCopy.transform.DOLocalMove(transform.localPosition,TweenDuration).SetEase(Ease.OutBack);
    12.     }
    13. }
    14.  
    Would this work or would the constant creation and destruction of tweens at such a high rate be problematic?

    I am aware i could do this myself by via simple vector maths in the update function however the tweens built easing over the course of the interpolation is what i am interested in having. Although of course it might look odd since it will apply to each individual one rather than over all of them...Either way, thoughts?
     
  31. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    Nono, a Sequence is like a movie clip which can't be edited after creation, but a Tweener (which is what you're creating with DOLocalMove) can :) Check out ChangeEndValue.
     
  32. Nemial

    Nemial

    Joined:
    Feb 25, 2014
    Posts:
    16
    That is awesome, However a little nudge in the right direction on usage, i tried using it and i can either to get it move either at a snails pace despite the tween having a duration of 0.5f or it does not move at all if i set startSnap value to false. Heres what i have

    Code (CSharp):
    1.  
    2. _trackTween = _displayCopy.transform.DOLocalMove(transform.localPosition,0.5f);
    3.  
    4. protected virtual void Update()
    5. {
    6.     if(isDoingThing)
    7.     {
    8.         _trackTween.ChangeEndValue(transform.localPosition,true);
    9.  
    10.         float distance = Vector3.Distance(_displayCopy.transform.localPosition, transform.localPosition);
    11.         if(distance < 5)
    12.         {
    13.             _displayCopy.DoKill();
    14.             isDoingThing = false;
    15.             GameObject.Destroy(_displayCopy);
    16.             widget.SetVisible(true);
    17.         }
    18.     }
    19. }
    20.  
     
    Last edited: Oct 13, 2014
  33. YaVeTaL

    YaVeTaL

    Joined:
    Sep 25, 2014
    Posts:
    29
    Okay, first serious (actually, i hope, not that serious) issue.
    Generally, everything works fine for a quite long time, but then i got this.



    In most cases, i'm using Restart(), but in one place i'm creating new tweens (still didnt get my hands on ChangeEndValue). Can it be a reason? I expected autocleaner to deal with issues like that.
     
  34. MrEsquire

    MrEsquire

    Joined:
    Nov 5, 2013
    Posts:
    2,712
    Seems you using a very old version, have you tried to upgrade to latest and see what happens.
     
  35. haddad

    haddad

    Joined:
    Apr 18, 2013
    Posts:
    4
    Hello,

    DOTween seems promising. As I hate iTween myself :p

    However, I think I don't understand how OnComplete works.

    Code (CSharp):
    1. public void Animate(Transform target,string sprite,Color color) {
    2.         Transform animationCard = GameObject.Find("Animation Card").transform;
    3.         tk2dSprite animationCardSprite = animationCard.GetComponent<tk2dSprite>();
    4.         float duration = 0.4f;
    5.  
    6.         animationCardSprite.SetSprite(sprite);
    7.  
    8.         animationCard.localScale = new Vector3(1.0f,1.0f,1.0f);
    9.         animationCard.localPosition = GameController.higlightedHandCard.transform.position;
    10.         animationCard.localRotation = GameController.higlightedHandCard.transform.localRotation;
    11.  
    12.         animationCard.DOMove(target.position,duration);
    13.         animationCard.DORotate(target.rotation.eulerAngles,duration);
    14.         animationCard.DOScale(new Vector3(0.5f,0.5f,1.0f),duration);
    15.         DOTween.To(()=> animationCardSprite.color, x=> animationCardSprite.color = x, color, duration).onComplete(SetState);
    16.     }
    I get this error:
    Code (CSharp):
    1. error CS1593: Delegate `DG.Tweening.Core.TweenCallback' does not take `1' arguments
    please help.
     
  36. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    @YaVeTaL Yup, as @MrEsquire noticed that's a bug that was solved a while ago. Updating should fix everything :)

    @Nemial Keeping startSnapValue to TRUE is definitely what you want, but it goes to a snail's pace because each time the duration is reset to 0.5f and the tween restarts from its current position. So you'll need to change the duration too, subtracting the current elapsed time:
    Code (csharp):
    1. _trackTween.ChangeEndValue(transform.localPosition, 0.5f - _trackTween.Elapsed(), true);
     
  37. haddad

    haddad

    Joined:
    Apr 18, 2013
    Posts:
    4
    Nevermind. I got it working like this.

    Code (CSharp):
    1. DOTween.To(()=> animationCardSprite.color, x=> animationCardSprite.color = x, color, duration).OnComplete(()=>
    2.         {
    3.             SetState();
    4.         });
     
  38. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    @haddad Ooops sorry you must've posted while I was replying and thus didn't notice your first question. If the function you want to call doesn't take any parameter, you can do as you wrote initially. The error was that you wrote onComplete with a lowercase first letter instead than an uppercase one (OnComplete), thus you were targeting the callback variable and not the setting.
     
  39. Nemial

    Nemial

    Joined:
    Feb 25, 2014
    Posts:
    16
    I thought that might have been the case that the duration was being reset, but i assumed if you did not change it it would remain as the elapsed time to preserve state. Now however i have implemented your suggestion and...it still moves at a snails pace...And after a bit of experimenting i realise why...the functionality i'm trying to implement is that they start dragging an object and another object Tweens to it's position at a constant duration even if the end value, where they are touching changes with update, obviously this happens quite frequently and that means the duration - elapsedTime() will start to look the same and again it slows down the closer it gets. So at this point i am a little stumped as to how to proceed with using tweens to get this effect.

    I suppose another way would be to have a multiplier which scales the duration down as it get's closer to the endValue
     
    Last edited: Oct 14, 2014
  40. YaVeTaL

    YaVeTaL

    Joined:
    Sep 25, 2014
    Posts:
    29
    Surprisingly, same stuff happened at the latest version:


    It seems, there are too many active tweens: i have 42... well... 50 items with tweens at most at the same time.
     
    Last edited: Oct 14, 2014
  41. YaVeTaL

    YaVeTaL

    Joined:
    Sep 25, 2014
    Posts:
    29
    Another issue: if to define sequence in Start() as
    Code (CSharp):
    1. moveFromTop = DOTween.Sequence ();
    2.         moveFromTop
    3.             .Append (transform.DOLocalMoveX (0.5f, 0.3f).From ())
    4.             .SetAutoKill(false).Pause();
    This would cause some positioning issues: tiles are spawning at x = 0.5 even if i didnt call moveFromTop.Restart();

    If to remove .From(), it works fine (though, i still didnt Restart() this tween)
    Current version is 0.9.195

    PS: using .Append (transform.DOMoveX (0.5f, 0.3f).From()) also provides same problem. Removing .From() also removes problem here.
     
    Last edited: Oct 14, 2014
  42. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    @Nemial Try creating a barebone project that replicates what you're trying to achieve, so I'll take a look at it.

    @YaVeTaL Maybe you set AutoKill to false on them so when they're complete they stay active?

    About the From issue, it's the nature of FROM tweens: targets immediately jump to the FROM position (my bad for not adding a note to the website about this, now I just did).
     
  43. YaVeTaL

    YaVeTaL

    Joined:
    Sep 25, 2014
    Posts:
    29
    Hm.. and Destroy() would not be able to destroy item, because tweens would be still active? How can i force them to be deleted? Simply set AutoKill(true) when i dont need item anymore?

    EDIT: nope, that didnt help 0_0
     
    Last edited: Oct 14, 2014
  44. YaVeTaL

    YaVeTaL

    Joined:
    Sep 25, 2014
    Posts:
    29
    Also, i just checked documentation, it is said

    Actually, you have to worry: in my case, when i hit a limit, some strange things started to happen: sequences didnt play till the end, stopped at halfway - everything becomes really messy. Kinda tile should had moved till the end of the screen, but stopped in a middle, and so on.
     
  45. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    @YaVeTaL About killing tweens, if you destroy their target the tween is killed automatically only if it's playing, otherwise it doesn't know if its target still exists or not. To kill a tween you don't change AutoKill, but directly kill it, either from a reference or calling DOKill from their target:
    Code (csharp):
    1. myTweenReference.Kill();
    2. myTweenTarget.DOKill():
    As a recommendation, you should always kill a tween when you know it's not needed anymore.
    Otherwise, you can call DOTween.Validate in any moment to clear any tween whose target was destroyed, but that is an expensive operation so use it with care.

    About the second issue, everything works correctly here. You should get a warning when your tweens capacity is increased: maybe it's been called too many times in a single frame and thus the log is slowing down the framerate and things stutter? Can you check that out?
     
  46. fionivar82

    fionivar82

    Joined:
    Oct 15, 2014
    Posts:
    4
    Just starting to try this out now, and so far it's working great. I am having a bit of trouble getting a simple "rolltomousevector" tween working though. Obviously the vector3(90,0,0) is the issue, but I figured it would just be the forward vector of the transform.

    Any suggestions on how to get a cube rolling to the destination?

    Code (CSharp):
    1.     public void Update()
    2.     {
    3.         Vector3 mousePos = Input.mousePosition;
    4.         if (Input.GetMouseButtonDown(1))
    5.         {
    6.             Plane planed = new Plane(Vector3.up, 0);
    7.             float distd;
    8.             Ray rayd = Camera.main.ScreenPointToRay(mousePos);
    9.             if (planed.Raycast(rayd, out distd))
    10.             {
    11.                 Vector3 point = rayd.GetPoint(distd);
    12.                 Vector3 newPoint = point;
    13.                 newPoint.y = 1.0f; //placeholder
    14.                 transform.LookAt(newPoint);
    15.                 transform.DOLocalAxisRotate(new Vector3(90,0,0), 1).SetAs(new TweenParms().SetLoops(-1));
    16.                 transform.DOMove(newPoint, 10);
    17.             }
    18.         }
    19.     }
     
  47. Nemial

    Nemial

    Joined:
    Feb 25, 2014
    Posts:
    16
    I did so and exported a package, to see what I'm on about click and drag the faces upwards to take them off the scrollview they are on and a copy should come from the top but at the slow pace i mentioned.

    EDIT:attachment removed
     
    Last edited: Oct 15, 2014
  48. YaVeTaL

    YaVeTaL

    Joined:
    Sep 25, 2014
    Posts:
    29
    That works fine, thanks!

    In that case, problem is not with warning, but with gameplay in general. While limit is not reached, tiles behavior is fine: new tiles are "jumps" onboard ( i mean, on board :)), and when tiles are matched, they are moving to the edge of the screen. But once limit is reached, some strange things started to happen: tiles animation is not working till the end, so tile stops on a half way to its destination place.
     
  49. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    @fionivar82 I tried to replicate it (though without the plane but just with a roll in a random direction) and it works perfectly. Some considerations on your code though:
    Code (csharp):
    1. // This
    2. transform.DOLocalAxisRotate(newVector3(90,0,0), 1).SetAs(new TweenParms().SetLoops(-1));
    3. // Can be written like this (much simpler)
    4. transform.DOLocalAxisRotate(newVector3(90,0,0), 1).SetLoops(-1);
    5. // Or even better, to make it roll only for the duration of the move tween,
    6. // set the loops to 10 (so the duration of the roll tween is the same as the move tween)
    7. transform.DOLocalAxisRotate(newVector3(90,0,0), 1).SetLoops(10);
    Let me know how it goes.

    @Nemial I got it and am testing it, but please remove your attachment as soon as possible: there are things in there that shouldn't be public.

    @YaVeTaL Can you manage to replicate it in a barebone project and send it to me? I can't find a way to replicate the same issue here.
     
  50. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    @Nemial Ooops got it, my mistake in posting the first code sample. You want the current elapsed time to be subtracted from the current tween's duration (since it changes with every ChangeEndValue) and not from the total time:
    Code (csharp):
    1. _trackTween.ChangeEndValue(transform.localPosition,_trackTween.Duration()-_trackTween.Elapsed(),true);