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

DOTween (HOTween v2), a Unity tween engine

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

  1. flashframe

    flashframe

    Joined:
    Feb 10, 2015
    Posts:
    789
    One option is to nest another tween in the OnComplete callback of the first tween.

    Img.DOFillAmount(SetPoint, TweenTime).SetEase(EaseType).OnComplete(() => { DOVirtual.DelayedCall(1, () => IsQuestComplete(QuestRH, QuestInfo)); });

    But that doesn't technically delay the OnComplete callback, so may not be what you want.

    Edit - Did not refresh the page before @FuguFirecracker posted, sorry
     
  2. nareshbishtasus

    nareshbishtasus

    Joined:
    Jun 11, 2018
    Posts:
    36
    @FuguFirecracker @flashframe Thank you I think that will solve my problem.

    Also, Do you know why all the tweeners are getting played at the same time if I create a sequence beforehand(at Start()) and are getting played in sequence if I create the Sequence and assign it in the same frame?
    (Please refer to this video I know my explanation is vague because I don't know how to explain this)

    Video Link - bandicam 2021 07 01 02 09 13 767 - YouTube
     
  3. FuguFirecracker

    FuguFirecracker

    Joined:
    Sep 20, 2011
    Posts:
    419
    Sequences are set to Autoplay by default in your preferences.
    Change preferences to only autoplay Tweeners. [ remember that you will have to use .Play() chained method on your sequences when you want them to play ]
    Such is my recommendation.
     
  4. nareshbishtasus

    nareshbishtasus

    Joined:
    Jun 11, 2018
    Posts:
    36
    Oh, ok thank you.
     
  5. el_Guero

    el_Guero

    Joined:
    Sep 15, 2017
    Posts:
    185
    Thanks man. I really appreciate you taking the time. This helped me a lot.
     
    FuguFirecracker likes this.
  6. zdolezal

    zdolezal

    Joined:
    Sep 27, 2017
    Posts:
    75
    How to you animate `Button.colors.normalColor` the best way? Is this it?

    Code (CSharp):
    1. ColorBlock buttonBgColors = ButtonBg.colors;
    2. DOTween.To(() => buttonBgColors.normalColor, value => {
    3.                             buttonBgColors.normalColor = value;
    4.                             ButtonBg.colors = buttonBgColors;
    5. }, someColor, 0.5f);
     
  7. BimzyDev

    BimzyDev

    Joined:
    Dec 9, 2020
    Posts:
    3
    upload_2021-7-4_17-50-59.png
    Does anyone know if there is a way to make the target dynamic? I've been reading the documentation and caanot find a way to make the target position of my DoTween command update to my players position.
     
  8. FuguFirecracker

    FuguFirecracker

    Joined:
    Sep 20, 2011
    Posts:
    419
    OnUpdate in combination with ChangeValues() is what you require.
    Code (CSharp):
    1. public class LetsFollowThatFugger : MonoBehaviour
    2. {
    3.     public Transform ObjectOfInterest;
    4.  
    5.     void Start()
    6.     {
    7.         var goToTween = transform.DOMove(ObjectOfInterest.position, 10);
    8.         goToTween.OnUpdate(() => goToTween.ChangeValues(transform.position, ObjectOfInterest.position));
    9.     }
    10. }
     
    AlejMC and andreiagmu like this.
  9. whaleyb

    whaleyb

    Joined:
    Dec 5, 2018
    Posts:
    2
    I think I'm probably doing something dumb, but is there a way to make a tween repeatable? For example, I want to make it so that whenever the player interacts with the can, the kickCan tween is played. However, no matter what set up I've tried, I've only been able to get the can to be kicked once. After that interacting with the can does nothing.

    I think my issue might be based around a misunderstanding of how .SetRelative() works, and that the -10 z coordinates its moving its only relative to its initial position, but I'm not sure about that either.

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3. using DG.Tweening;
    4.  
    5. public class SidewalkDoTween : MonoBehaviour
    6. {
    7.     public Transform can;
    8.     public Tween kickCan;
    9.     IEnumerator Start()
    10.     {
    11.         yield return new WaitForSeconds(1);
    12.  
    13.         kickCan = can.DOJump(new Vector3(0, 0, -10), 1, 1, 1).SetRelative().Pause().SetRecyclable(true);
    14.  
    15.     }
    16.  
    17.     public void KickCan()
    18.     {
    19.         kickCan.Play();
    20.     }
    21. }
     
  10. FuguFirecracker

    FuguFirecracker

    Joined:
    Sep 20, 2011
    Posts:
    419
    That's not the issue at all...

    The issue is you've only created one tween in the Start() function and keep attempting to "Play" it after it has already played and is done... Repeated tweening calls for repeated tweens. Forget about recycling until you understand a bit more about how recycling works, because what you're doing is not it.

    Code (CSharp):
    1.    public void KickCan()
    2.     {
    3.         can.DOJump(new Vector3(0, 0, -10), 1, 1, 1).SetRelative().Play();
    4.     }
    Is all you need
     
  11. whaleyb

    whaleyb

    Joined:
    Dec 5, 2018
    Posts:
    2

    Thank you for your help! I had actually tried that configuration before but was having the same issue. However, with your confirmation, I was able to figure out it was actually an issue with my interaction script.
     
    FuguFirecracker likes this.
  12. Leger

    Leger

    Joined:
    Oct 9, 2016
    Posts:
    2
    It seems that DOPath has built in easing. Is there a way to turn that off?
     
  13. FuguFirecracker

    FuguFirecracker

    Joined:
    Sep 20, 2011
    Posts:
    419
    Code (CSharp):
    1. .SetEase()
    You can also set the default EaseType in Preferences when you [re]setup DOTween
     
  14. Leger

    Leger

    Joined:
    Oct 9, 2016
    Posts:
    2
    Not sure how I missed the default ease setting, Thank you!
     
    FuguFirecracker likes this.
  15. roy432002

    roy432002

    Joined:
    Jun 20, 2019
    Posts:
    18
    Is there a way to change the target while the tween is playing? Like moving the camera to a moving GameObject's position
     
  16. FuguFirecracker

    FuguFirecracker

    Joined:
    Sep 20, 2011
    Posts:
    419
    Literally, answered 7 posts prior to your asking.
     
  17. andreiagmu

    andreiagmu

    Joined:
    Feb 20, 2014
    Posts:
    175
    Hi! Has anyone used DOTween in a DOTS project? (with Unity ECS, entities, jobs, systems...)
    Does anyone have any tips about it?
     
    Vectrex likes this.
  18. YHX2000

    YHX2000

    Joined:
    Aug 2, 2015
    Posts:
    29
  19. andreiagmu

    andreiagmu

    Joined:
    Feb 20, 2014
    Posts:
    175
    Hi! I made a script for that kind of eyeroll animation. You can tweak the values/eases if needed.
    Code (CSharp):
    1. public class EyeRollTween : MonoBehaviour
    2. {
    3.     public Transform child;
    4.    
    5.     private void Start()
    6.     {
    7.         // Set initial position (iris pointing to the right)
    8.         transform.DORotate(new Vector3(0, -60f, 0), 0)
    9.             .SetRelative();
    10.        
    11.         // Rotate eye parent on the Y axis
    12.         transform.DORotate(new Vector3(0, 120f, 0), 1f)
    13.             .SetLoops(-1, LoopType.Yoyo)
    14.             .SetEase(Ease.Linear)
    15.             .SetRelative();
    16.        
    17.         // Rotate eye object on the X axis
    18.         child.DOLocalRotate(new Vector3(35f, 0, 0), 0.5f)
    19.             .SetLoops(-1, LoopType.Yoyo)
    20.             .SetEase(Ease.OutQuad)
    21.             .SetRelative();
    22.     }
    23. }

    To make the eyeroll animation, I had to create a parent gameobject (EyeParent) to rotate on the Y axis, and at the same time rotate my Eye (child) gameobject on the X axis. I had to do it this way because DOTween doesn't support using simultaneous DORotate tweens on the same target.
    More info here: http://forum.demigiant.com/index.php?topic=110.0

    So, attach the script to the parent object, set the reference to the child transform and it should work correctly.

    capture_20210721_210300_001.png
    eyeRoll.gif
     

    Attached Files:

    Last edited: Jul 22, 2021
    YHX2000 likes this.
  20. YHX2000

    YHX2000

    Joined:
    Aug 2, 2015
    Posts:
    29
    Thank you very much !
    I'll try tonight the script !
     
    andreiagmu likes this.
  21. gjs32

    gjs32

    Joined:
    Feb 27, 2016
    Posts:
    10
    Hi, I'm wondering if its possible to move an object along paths that are set on another gameobjects?

    EG: player moves into collider, player is taken along path that has been configured on the collider gameobject.

    Thanks!
     
  22. FuguFirecracker

    FuguFirecracker

    Joined:
    Sep 20, 2011
    Posts:
    419
    All things are possible. It's just a matter of being able to do it ;)
    I have no clue what this means, but if you have path information, you can write a method to pass that information to a tween.
     
  23. gjs32

    gjs32

    Joined:
    Feb 27, 2016
    Posts:
    10
    haha thanks for your reply and yeah I'm sorry I don't really know how to communicate with this stuff. Second try:

    I have a gameobject with collider and DOTweenPath components, and I'd like my player gameobject to be sent along that path when it enters the collider.

    I'm looking through the docs but can't seem to find a method that would take a path ID and move something along that path.
     
  24. FuguFirecracker

    FuguFirecracker

    Joined:
    Sep 20, 2011
    Posts:
    419
    You can get the Transform of the hit object and set up a tween in OnCollisionEnter()
    • Monobehaviour on your collider object.
    • Collision object's path cached as field.
    • OnCollisionEnter(){hit.in.transform.DoPath(cachedPath)} // or something like that
    OR!
    If you already got a tween going on your collision object, just bring the interloper along for the ride.


    colliderObjectTween.OnUpate( ()=> if(interloper) interloper.transform.position = this.transform.position ) // or something like that

    You will need to set a bool in the OnColision to say that the interloper has hit.
     
  25. gjs32

    gjs32

    Joined:
    Feb 27, 2016
    Posts:
    10
    Ah thank you so much! Will try this now :)

    Update: first method is working great, thanks for your help Fugu!
     
    Last edited: Jul 26, 2021
    FuguFirecracker likes this.
  26. mhardy

    mhardy

    Joined:
    Apr 3, 2011
    Posts:
    48
    I'm constantly running into capacity being increased.

    DOTWEEN ► Max Tweens reached: capacity has automatically been increased from 200/50

    This is in MyButton:

    Code (CSharp):
    1. public void Run()
    2.     {
    3.         // clone ourself
    4.         var clone = Instantiate(gameObject, transform.parent);
    5.  
    6.         // Scale out, fade, then kill our clone
    7.         Sequence sequence = DOTween.Sequence();
    8.         sequence.Join(clone.transform.DOScale(ScaleFactor, FadeDuration))
    9.                         .Join(clone.GetComponent<Image>().DOFade(0, FadeDuration))
    10.                         .OnComplete(() =>
    11.                         {
    12.                             Destroy(clone);
    13.                         }).Play();
    14.  
    15.     }
    During MyButton.OnClick(), Run() gets called. It clones itself, runs the sequence, then the clone kills itself. It works great, but if I click the button, only 15 times, it always tries to increase capacity. Keep clicking and capacity goes to 500/50, then to 500/125, 500/312, etc...

    How should this be done so the tweens either get reused, or recycled?
     
  27. FuguFirecracker

    FuguFirecracker

    Joined:
    Sep 20, 2011
    Posts:
    419
    Perhaps you'd care to read my article on Building a Better Button with DOTween which I scribed for the now defunct Unity Connect ... Building a Better Button With DOTween

    It probably solves NONE of your issues! .Just thought if you're gonna build buttons, you should build better ones ;)
    ou may like the article or it may be totally irrelevant. Up to you.

    Actually, the ActionStack paradigm I detail may help you with race conditions from incessant clicking.
    But I'm thinking you want persons ferociously clicking your buttons. Should be trivial to modify that method to allow a finite amount of clicks. We don't need 500 - Or maybe you do - I dunno.

    Addressing your actual issue, I really cant say for certain what's going on with your cascade of tweens. Generally that's caused by tweens being created in an Update loop. [ please see repeated posts in this forum with me raging against people doing that lol ]

    You're gonna need to fire up the profiler / debugger to see what's going on where.

    I might suggest removing some complexity first and seeing if the issue persists.
    For instance ... get rid of the sequence and try with 1 tween only. Perhaps the Fade tween.

    You still got all those tweens being created ? If so it's not a problem with sequences ... if NOT, well... we're getting a hint of where the problem lies...
     
  28. mhardy

    mhardy

    Joined:
    Apr 3, 2011
    Posts:
    48
    I'll take a look at that article, thanks.

    It's not so much a concern with furious clicking, but I want to ensure, in the course of playing for awhile, the tweens are getting reused or recycled and not just filling up the cache and burning memory.

    I tried this simplified version and the capacity still increases. I suspect there's a best practice for this but I can't figure out what it is. I've read the FAQ on 'How does tween caching work' but I could really use some examples with code.

    Code (CSharp):
    1.     public void Run()
    2.     {
    3.         var clone = Instantiate(gameObject, transform.parent);
    4.         clone.GetComponent<Image>().DOFade(0, FadeDuration)
    5.              .OnComplete(() => { Destroy(clone); }).Play();
    6.     }
    And no, I have read the many posts regarding Update() - I'm not doing it there. Only when a user clicks a button.
     
  29. FuguFirecracker

    FuguFirecracker

    Joined:
    Sep 20, 2011
    Posts:
    419
    Code (CSharp):
    1.  
    2. using DG.Tweening;
    3. using UnityEngine;
    4. using UnityEngine.UI;
    5.  
    6. namespace FuguFirecracker
    7. {
    8.     public class ClickityBoo : MonoBehaviour
    9.     {
    10.         public void Run()
    11.         {
    12.             var clone = Instantiate(gameObject, transform.parent);
    13.             clone.GetComponent<Image>().DOFade(0, 3)
    14.                 .OnComplete(() => Destroy(clone)).Play();
    15.         }
    16.     }
    17. }
    I have this code [ identical to yours ] on a Unity.UI Button ...
    Run() is called from the Unity EventSystem OnClick()
    I can click the ever-lovin'-stuffin' out of it and I do not encounter the runaway tween cascade.

    Code (CSharp):
    1.  
    2. public void Run()
    3.         {
    4.             var clone = Instantiate(gameObject, transform.parent);
    5.             clone.transform.DOScale(3, 3);
    6.             clone.GetComponent<Image>().DOFade(0, 3)
    7.                 .OnComplete(() => Destroy(clone)).Play();
    8.         }
    Two tweens concurrent.. No problem.

    Code (CSharp):
    1.  
    2. public void Run()
    3.         {
    4.             var clone = Instantiate(gameObject, transform.parent);
    5.          
    6.             var sequence = DOTween.Sequence();
    7.             sequence.Join(clone.transform.DOScale(3, 3))
    8.                 .Join(clone.GetComponent<Image>().DOFade(0, 3))
    9.                 .OnComplete(() => Destroy(clone) ).Play();
    10. }
    Your first posted snippet with sequence no problems ... Tweens only ever reach the number of Buttons on screen.
    You'll be relieved to hear that your problems lie elsewhere. ;)

    clickityBoo.gif

    ### EDIT
    Just to be clear ... all you need to "Recycle" your tweens is to check that option in the Preference Tab of the DOTween Setup Utility. DOTween will automatically pool your tweens for you when viable.

    Pooling is not your problem here. Your doing something somewhere else that is causing the tween spam. Nothing wrong with your tweening code.
     
    Last edited: Jul 29, 2021
    mhardy likes this.
  30. mhardy

    mhardy

    Joined:
    Apr 3, 2011
    Posts:
    48
    Wow, @FuguFirecracker! How have I never seen the DOT Tween Component runtime stats!! That is a game changer for debugging. Once I found it, I noticed this...

    AutoKill had gotten turned off. Turned that on, and everything is good! Smashing those clicks and never a capacity increase.

    Makes for some really cool buttons.

    Thanks so much for your time on this.
     

    Attached Files:

    FuguFirecracker likes this.
  31. ALIENPANDA

    ALIENPANDA

    Joined:
    Jan 14, 2020
    Posts:
    32
    Hello DOTweeners,
    I have a small doubt. I'm not able to prefab the DOTween Visual Manager. Even after doing so, the script will be removed somehow. Is there a way to do it?:rolleyes:
     
    Last edited: Jul 29, 2021
  32. Tehenauin

    Tehenauin

    Joined:
    Oct 18, 2018
    Posts:
    43
    Hi!
    I want to tween the position of a character (eased) and want to set the speed in its animation Controller so that the animation playes faster if it walks faster.
    How do I get the speed?

    In my case I don't even use tweening, but only the DOVirtual.EasedValue(...) function inside of the processFrame from a playableBeahaviour, so it would be cool it there was something like DOVirtual.EasedValueSpeed(float t, Ease ease) to get the speed of an ease-curve at a specific time, so basically the derivative of the ease/curve.
     
  33. FuguFirecracker

    FuguFirecracker

    Joined:
    Sep 20, 2011
    Posts:
    419
    AutoKill, turned off you say ? Never entered my mind. I must remember this from hereon as a likely culprit before I accuse others of Update abuse ;)
     
  34. FuguFirecracker

    FuguFirecracker

    Joined:
    Sep 20, 2011
    Posts:
    419
    The what now? Is it called that, or is that what you decided to name it ?
     
  35. ALIENPANDA

    ALIENPANDA

    Joined:
    Jan 14, 2020
    Posts:
    32

    Attached Files:

  36. FuguFirecracker

    FuguFirecracker

    Joined:
    Sep 20, 2011
    Posts:
    419
    Ah ha! I see ...
    I never use it. Forgot what it was called. Thought you might be referring to the Runtime inspector.

    I'll take a look later this afternoon.
     
  37. FuguFirecracker

    FuguFirecracker

    Joined:
    Sep 20, 2011
    Posts:
    419
    I am
    • Create Cube
    • Add DOTween Animation Component
    • Add Visual manager
    • Create Prefab
    • Visual Manager continues to exist
    No problems here.

    When does this happen? When you press Play? When you create the prefab? When close your eyes and think of England?

    I am not encountering this issue. All I can tell you is that it is not "expected behaviour"
     
    Last edited: Jul 29, 2021
  38. ALIENPANDA

    ALIENPANDA

    Joined:
    Jan 14, 2020
    Posts:
    32
    I updated the DOTween. now it is working perfectly. Thank you for the help @FuguFirecracker ;)
     
    FuguFirecracker likes this.
  39. JosephOPossum

    JosephOPossum

    Joined:
    Dec 17, 2016
    Posts:
    4
    Hey everyone, I've been beating my head against a wall trying to get this thing working. I'm looking to have text that wiggles up and down smoothly, and I've managed to almost get there.

    The white dots in the next image are periods in a TMP text object. As you can see, it does work fine after stabilizing a bit.
    Screenshot 2021-08-02 203509.png

    But here's how it looks when the text first flushes out (disregard the fade, that's another text effect i'm using)
    Screenshot 2021-08-02 203626.png

    There's something wrong with how i'm initially setting the positions of the characters, and my calculation for the time to get to the target point. The characters come out with breaks inbetween them.

    Here's the relevant code I have so far.
    Code (CSharp):
    1.             Sequence tempWiggleSequence = DOTween.Sequence();
    2.             float tDistance = 15f;
    3.             float tTime = 1f;
    4.             float tFrequency = 0.1f;
    5.             charAnimator.SetCharOffset(index, new Vector3(0,GenerateStartingCharacterOffset(index, tFrequency, tDistance/2, tDistance),0));
    6.  
    7.             float xLinearPos = index*tFrequency;
    8.  
    9.             if ((xLinearPos)%(Mathf.PI*2) <= Mathf.PI){ // Going down...
    10.                 Sequence wiggle = DOTween.Sequence();
    11.                 wiggle.Append(
    12.                     DOTween.To(() => charAnimator.GetCharOffset(index), x => charAnimator.SetCharOffset(index,x), new Vector3(0,tDistance*1.5f,0), tTime)
    13.                     .SetEase(Ease.InOutSine)
    14.                 );
    15.                 wiggle.Append(
    16.                     DOTween.To(() => charAnimator.GetCharOffset(index), x => charAnimator.SetCharOffset(index,x), new Vector3(0,0,0), tTime)
    17.                     .SetEase(Ease.InOutSine)
    18.                 );
    19.                 wiggle.SetLoops(int.MaxValue);
    20.                 tempWiggleSequence.Prepend(
    21.                     DOTween.To(() => charAnimator.GetCharOffset(index), x => charAnimator.SetCharOffset(index,x), new Vector3(0,0,0), tTime*((xLinearPos%Mathf.PI)/Mathf.PI))
    22.                     .SetEase(Ease.InOutSine)
    23.                 );
    24.  
    25.                 tempWiggleSequence.Append(wiggle);
    26.          
    27.             } else { // Going Up
    28.                 Sequence wiggle = DOTween.Sequence();
    29.                 wiggle.Append(
    30.                     DOTween.To(() => charAnimator.GetCharOffset(index), x => charAnimator.SetCharOffset(index,x), new Vector3(0,0,0), tTime)
    31.                     .SetEase(Ease.InOutSine)
    32.                 );
    33.                 wiggle.Append(
    34.                     DOTween.To(() => charAnimator.GetCharOffset(index), x => charAnimator.SetCharOffset(index,x), new Vector3(0,tDistance*1.5f,0), tTime)
    35.                     .SetEase(Ease.InOutSine)
    36.                 );
    37.                 wiggle.SetLoops(int.MaxValue);
    38.                 tempWiggleSequence.Prepend(
    39.                     DOTween.To(() => charAnimator.GetCharOffset(index), x => charAnimator.SetCharOffset(index,x), new Vector3(0,tDistance*1.5f,0), tTime*((xLinearPos%Mathf.PI)/Mathf.PI))
    40.                     .SetEase(Ease.InOutSine)
    41.                 );
    42.                 tempWiggleSequence.Append(wiggle);  
    43.             }
    44.             loopSequence.Join(tempWiggleSequence);
    45.  
    And this is the function i'm using to initially set the positions of the characters

    Code (CSharp):
    1.     private static float GenerateStartingCharacterOffset(float xPosition, float xFrequency, float yZeroPosition, float yMagnitude){
    2.         return (float)(Math.Cos(xPosition*xFrequency)*yMagnitude+yZeroPosition);
    3.     }
    4.  
    I think the issue is in my math. I don't know of any other implementations for what I want, there's not much CharTweener stuff out there.

    Help would be greatly appreciated. DOTween has been awesome for me so far, i'm just having a tough time getting these darn letters to move haha.
     
  40. FuguFirecracker

    FuguFirecracker

    Joined:
    Sep 20, 2011
    Posts:
    419
    Here's a really simple implementation of the sine wave effect you're after.
    Change the SetEase to InOutSine according to your needs.

    If you're able to tween the TMP_Text character vertices, you should be clever enough to adapt this simpler approach. ;)

    Here's some valid math

    Code (CSharp):
    1.  
    2. float y = Mathf.Rad2Deg * Mathf.Atan(Freq * Amp * Mathf.Cos(Freq * i - Time.time * Speed));
    3.  
    4. // where:  Freq, Amp, Speed are  serialized fields
    5. // i is an iterator denoting index of object
    6. // Time.time is plain ol Unity's Time class
    But if you're using DOTween, you don't need to do these calculations.
    Just setup up a an InOutSine tween using the objects' indices as offset as show in the linked example.
     
    JosephOPossum likes this.
  41. Peacewise

    Peacewise

    Joined:
    Feb 27, 2014
    Posts:
    52
    DoTween is fantastic.

    Something I'm missing from it is Blendable versions of PunchPosition and PunchScale. The punches are so useful, but with multiples potentially overlapping, they can't be used since there are no Blendable versions.

    I've had to write my own, very basic, Blendable punches by stringing together Blendable Position changes or Blendable Scale changes. But I would much rather have this built-in.

    Please consider adding these!
     
  42. justtime

    justtime

    Joined:
    Oct 6, 2013
    Posts:
    424
    @Demigiant
    Please add to DoTweenModuleUI
    Code (CSharp):
    1. public static TweenerCore<float, float, FloatOptions> DOMinHeight(this LayoutElement target, float endValue, float duration, bool snapping = false)
    2.         {
    3.             TweenerCore<float, float, FloatOptions> t = DOTween.To(() => target.minHeight, x => target.minHeight = x, endValue, duration);
    4.             t.SetOptions(snapping).SetTarget(target);
    5.             return t;
    6.         }
    7.      
    8.         public static TweenerCore<float, float, FloatOptions> DOMinWidth(this LayoutElement target, float endValue, float duration, bool snapping = false)
    9.         {
    10.             TweenerCore<float, float, FloatOptions> t = DOTween.To(() => target.minWidth, x => target.minWidth = x, endValue, duration);
    11.             t.SetOptions(snapping).SetTarget(target);
    12.             return t;
    13.         }
     
    Last edited: Aug 11, 2021
    AlejMC likes this.
  43. JosephOPossum

    JosephOPossum

    Joined:
    Dec 17, 2016
    Posts:
    4
    Thanks for the reply! This is very helpful, I hadn't considered doing a yoyo looping before, though that does make much more sense than what i've been doing.

    After fiddling around with it some more, I ended up with something I was... content with at least haha.

    Though, I've also decided to look into other text animation tools for the future. DOTween is extremely useful but for my use case, I need something more dedicated to text animations.

    Thanks for the help though, this implementation will do just fine until I migrate my logic to a different system!
     
    FuguFirecracker likes this.
  44. umair21

    umair21

    Joined:
    Mar 4, 2016
    Posts:
    147
    Hi, Struggling with this issue, can someone help?
    I want to add multiple dotwee paths to my chopper gameobject and then from code, I want to play them with ID. There's a field for ID in DotweePath component but I can't find a code to play path by ID just like we do with DotweenAnimation's DOPlayByID method.
     
  45. FuguFirecracker

    FuguFirecracker

    Joined:
    Sep 20, 2011
    Posts:
    419
    Code (CSharp):
    1.  
    2. private IEnumerator Start()
    3.     {
    4.  
    5.         transform.DOPath(
    6.              new[] { Vector3.back, Vector3.down, Vector3.forward, Vector3.left, Vector3.up,Vector3.right }, 3, PathType.CatmullRom)
    7.             .SetId(555)
    8.             .Pause();
    9.  
    10.         yield return new WaitForSeconds(3);
    11.  
    12.         DOTween.Play(555); // <- Play by ID RIGHT HERE
    13.     }
     
  46. FuguFirecracker

    FuguFirecracker

    Joined:
    Sep 20, 2011
    Posts:
    419
    Looks useful but I'm not the developer of DOTween.
    I just shoot my mouth off around here from time to time ;)
     
    justtime likes this.
  47. farazk86

    farazk86

    Joined:
    May 31, 2017
    Posts:
    194
    Hi guys,

    After upgrading to unity 2020, I am facing the following trouble:

    image_2021-08-11_002548.png

    the tweens are not recognized and have the red squigly under them. Also DOAnchorPos does not show up in the auto complete suggestions of intellisense either.

    Strange thing is that the code works as expected - its just showing errors in the editor.. as can be seen from above screenshot.

    Does anyone else have this problem?

    I have upgraded and reimported DoTween and also ran the setup again.. :(
     
  48. flashframe

    flashframe

    Joined:
    Feb 10, 2015
    Posts:
    789
    farazk86 likes this.
  49. sharkwithlasers

    sharkwithlasers

    Joined:
    Dec 8, 2012
    Posts:
    23
    Hi there!

    DOTween has been a must-have asset for me in all my projects. Thank you for making it!

    I'm curious, is it possible to start a tween mid ease?

    for example. Let's say that my x-position is currently at 4. I'd like it to be at 10. But I'd like the easing to be as if it's 4/10 of the way through the easing function (so it's as if the easing starting as if the x-position was 0).

    Perhaps another way of putting is...let's say I wanted to follow this animation with an initial position of x = 0 (destination of x = 10, over 1 second):
    `transform.DOMoveX(10, 1f).SetEase(Ease.InSine)`.

    But I wanted to start initially at x = 4 (and to make sure that the animation time left would follow the previous animation curve). Is this possible in DOTween?

    Thanks!
     
  50. flashframe

    flashframe

    Joined:
    Feb 10, 2015
    Posts:
    789
    You could use a Goto() and optionally ChangeStartValue() to do this. Initially reset the x position back to zero, and then immediately use Goto to return it to its original starting point.

    Code (CSharp):
    1. transform.position = new Vector3(0, transform.position.y, transform.position.z);
    2. transform.DOMoveX(10f, 1f).SetEase(Ease.InSine).Goto(0.4f, true);
    If you don't know the exact x position when you start the tween, you could calculate that first and use that as the parameter of Goto

    Code (CSharp):
    1. float t = transform.position.x / 10;