Search Unity

DOTween (HOTween v2), a Unity tween engine

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

  1. caglarenes

    caglarenes

    Joined:
    Jul 9, 2015
    Posts:
    45
    Hello :)

    DOPunchPosition Tweener gives an error and doesn't apply ChangeEndValue or ChangeStartValue function calls with passing Vector3


    Code (CSharp):
    1. DOTWEEN ► ChangeEndValue: incorrect newEndValue type (is UnityEngine.Vector3, should be UnityEngine.Vector3[])
    2. UnityEngine.Debug:LogWarning (object)
    3. DG.Tweening.Core.Debugger:LogWarning (object,DG.Tweening.Tween) (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__DOTween/_DOTween.Assembly/DOTween/Core/Debugger.cs:46)
    4. DG.Tweening.Core.TweenerCore`3<UnityEngine.Vector3, UnityEngine.Vector3[], DG.Tweening.Plugins.Options.Vector3ArrayOptions>:ChangeEndValue (object,single,bool) (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__DOTween/_DOTween.Assembly/DOTween/Core/TweenerCore.cs:84)
    5. GameManager/<AnimateEffect>d__96:MoveNext () (at Assets/Scripts/GameManager.cs:678)
    6. UnityEngine.UnitySynchronizationContext:ExecuteTasks ()

    It wants Vector3 array but Vector3[] also doesn't work. Documentations don't have enough information or I can't find. Does DOPunchPosition function support ChangeEndValue()?
     
  2. jmattarock_unity

    jmattarock_unity

    Joined:
    Mar 10, 2018
    Posts:
    25
    HI Guys,

    need a little help.. Is there away to covert this to DOtween?


    Code (CSharp):
    1. playerCam.localPosition = Vector3.Lerp(playerCam.localPosition, newZoom, Time.deltaTime * speed);
    2. playerCam.localRotation = Quaternion.Lerp(playerCam.localRotation, newZoomRotation, Time.deltaTime * speed);
     
  3. AmitChBB

    AmitChBB

    Joined:
    Feb 16, 2021
    Posts:
    37
    Hi there,
    Just wondering - after I told an object to DOTween, is there a way for me to check from a different object/script if that object is tweening or not?

    I'm asking because I want to be able to dynamically change the speed of dotweens during runtime.
     
  4. Twyker_gp

    Twyker_gp

    Joined:
    Dec 4, 2018
    Posts:
    29
    Is there a new/better way to use DoTween with UniRx now? :)
     
  5. LE-Peter

    LE-Peter

    Joined:
    Sep 15, 2020
    Posts:
    44
    How do I debug this and find where the null target is? As you can see from the screenshot, the stack trace is showing just for DOTween and none of my own code. As far as I can see, all my components have their fields assigned.. but there's a lot to check ..

    Screenshot 2021-03-10 171211.png
     
  6. Sparkline

    Sparkline

    Joined:
    Feb 8, 2013
    Posts:
    121
    Hello. I wish to use DOTweenAnimation component to shake position of a gameobject. I see all parameters in inspector (like vibrato, randomness, snapping) except fadeOut, the one i really need. Did you miss it :)?
     
  7. techniquea2z

    techniquea2z

    Joined:
    Jun 3, 2017
    Posts:
    37
    Hey!

    Not really a bug or anything, just wondering if I'm going about this correctly.

    I'm going for a PerCharacter TextMesh animation where the letters spill in from offscreen on the right into the center.

    Wait there for a few seconds.

    Then go offscreen to to the left.

    The code:

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3.  
    4. using UnityEngine;
    5. using UnityEngine.UI;
    6.  
    7. using Sirenix.OdinInspector;
    8. using TMPro;
    9. using DG.Tweening;
    10.  
    11.  
    12.  
    13. public class PhaseDisplay : SerializedMonoBehaviour
    14. {
    15.     [SerializeField] private Dictionary<TurnPhase, Color> turnColors = new Dictionary<TurnPhase, Color>();
    16.  
    17.     private TurnPhase _phase;
    18.     private Image _backgroundOverlay;
    19.     private Image _phaseNameHolder;
    20.     private TextMeshProUGUI _phaseText;
    21.  
    22.     private bool _completedSetup = false;
    23.     private List<Vector3> _centeredCharacters;
    24.     private Color _originalBGColor;
    25.  
    26.     public void Show(TurnPhase phase)
    27.     {
    28.         _phase = phase;
    29.        
    30.         Init();
    31.  
    32.  
    33.         _originalBGColor = _backgroundOverlay.color;
    34.  
    35.         _phaseNameHolder.color = turnColors[_phase];
    36.         _phaseText.text = $"{_phase.ToString()} Phase";
    37.         _phaseText.ForceMeshUpdate(true, true);
    38.        
    39.         CacheCenteredTextPositions();
    40.         HideAll();
    41.         StartCoroutine(SetTextOffToTheRight());
    42.         StartCoroutine(AnimatePhaseTextIn());
    43.     }
    44.  
    45.  
    46.     private void Start() {
    47.         Show(TurnPhase.Player);
    48.     }
    49.  
    50.     private void Init()
    51.     {
    52.         _backgroundOverlay = GetComponent<Image>();
    53.         _phaseNameHolder = GetComponentInChildren<Image>();
    54.         _phaseText = GetComponentInChildren<TextMeshProUGUI>();
    55.     }
    56.  
    57.  
    58.     private void HideAll()
    59.     {
    60.         Color bgColorHidden = _backgroundOverlay.color;
    61.         bgColorHidden.a = 0;
    62.         _backgroundOverlay.color =  bgColorHidden;
    63.  
    64.         Color holderColorHidden = _phaseNameHolder.color;
    65.         holderColorHidden.a = 0;
    66.         _phaseNameHolder.color = holderColorHidden;
    67.  
    68.         Color textColorHidden = _phaseText.color;
    69.         textColorHidden.a = 0;
    70.         _phaseText.color = textColorHidden;
    71.     }
    72.  
    73.     private void ShowAll()
    74.     {
    75.         _backgroundOverlay.color = _originalBGColor;
    76.         _phaseNameHolder.color = turnColors[_phase];
    77.  
    78.         Color textColorShown = _phaseText.color;
    79.         textColorShown.a = 1;
    80.         _phaseText.color = textColorShown;
    81.  
    82.     }
    83.  
    84.     private void CacheCenteredTextPositions()
    85.     {
    86.         _centeredCharacters = new List<Vector3>();
    87.  
    88.         for (int i = 0; i < _phaseText.textInfo.characterCount; ++i)
    89.         {
    90.             var info = _phaseText.textInfo.characterInfo[i];
    91.             Vector3 center = (info.bottomLeft + info.bottomRight + info.topLeft + info.topRight) / 4;
    92.            
    93.             _centeredCharacters.Add(center);
    94.         }
    95.     }
    96.  
    97.     private IEnumerator SetTextOffToTheRight()
    98.     {
    99.         DOTweenTMPAnimator animator = new DOTweenTMPAnimator(_phaseText);
    100.         Sequence sequence = DOTween.Sequence();
    101.  
    102.         var offScreenRightPosition = new Vector3(
    103.           _phaseText.rectTransform.rect.max.x + 100, _phaseText.rectTransform.rect.center.y, 0
    104.         );
    105.  
    106.         for (int i = 0; i < animator.textInfo.characterCount; ++i) {
    107.             if (!animator.textInfo.characterInfo[i].isVisible) continue;
    108.  
    109.             yield return new WaitForSeconds(0.01f);
    110.  
    111.             sequence.Join(animator.DOOffsetChar(i, offScreenRightPosition, 0.01f));
    112.         }
    113.     }
    114.  
    115.     private IEnumerator AnimatePhaseTextIn()
    116.     {
    117.         DOTweenTMPAnimator animator = new DOTweenTMPAnimator(_phaseText);
    118.         Sequence sequence = DOTween.Sequence();
    119.  
    120.  
    121.         sequence.onComplete += delegate() {
    122.             StartCoroutine(AnimatePhaseTextOut());
    123.         };
    124.  
    125.         ShowAll();
    126.  
    127.         for (int i = 0; i < animator.textInfo.characterCount; ++i)
    128.         {
    129.             if (!animator.textInfo.characterInfo[i].isVisible) continue;
    130.        
    131.             var tweenTarget = _centeredCharacters[i];
    132.             yield return new WaitForSeconds(0.1f);
    133.  
    134.             sequence.Join(animator.DOOffsetChar(i, tweenTarget, 0.4f));
    135.         }
    136.     }
    137.  
    138.  
    139.     private IEnumerator AnimatePhaseTextOut()
    140.     {
    141.         DOTweenTMPAnimator animator = new DOTweenTMPAnimator(_phaseText);
    142.         Sequence sequence = DOTween.Sequence();
    143.  
    144.  
    145.         sequence.onComplete += delegate() {
    146.             FadeOut();
    147.         };
    148.         yield return new WaitForSeconds(5f);
    149.  
    150.  
    151.         for (int i = 0; i < animator.textInfo.characterCount; ++i) {
    152.             if (!animator.textInfo.characterInfo[i].isVisible) continue;
    153.        
    154.             var tweenTarget = new Vector3(_phaseText.rectTransform.rect.min.x - (40 + (50 * i)), _phaseText.rectTransform.rect.center.y, 0);
    155.             yield return new WaitForSeconds(0.1f);
    156.  
    157.             sequence.Join(animator.DOOffsetChar(i, tweenTarget, 0.4f));
    158.         }
    159.     }
    160.  
    161.     private void FadeOut()
    162.     {
    163.         Debug.Log("FadeOut");
    164.     }
    165.  
    166. }
    167.  
    It's.. sort of working? Since it requires that the text be visible, you can see a few milliseconds of jitter when moving from the center to the right (to prepare the transition to the center).

    It starts in the center, caches the position, moves the characters to the rgiht. Tweens to center, waits, then tweens offscreen to the left.

    The issue I am having is a question of "Is this the optimal way to do this?". Tha main issue though is inaccurate aching of characters' centered positions.

    A visual of it in action:



    Original centered position:

    https://i.imgur.com/JvC875h.png


    tl;dr:

    1. Is there a better way to tween to and from a position with TextMesh Pro.
    2. Is there a wiser way to handle this than what I've got going on?
     
  8. techniquea2z

    techniquea2z

    Joined:
    Jun 3, 2017
    Posts:
    37
    I mean, this is sort of one of those iterations of "bug or feature" lol

    it doesnt look bad, and it does the job I guess.

    I do want to be able to handle this more accurately in the future though. shaking text, etc. text animation effects, where I'll want to tween then return to original position.
     
  9. profGumidek

    profGumidek

    Joined:
    Aug 29, 2019
    Posts:
    9
    Hi everyone. Im trying to use a simple DOColor on SpriteRenderer but eventhough I have all setup the Spriterenderer (in fact all of them - DOMove works perfectly), I cant access it. Sry for a noob question. tx for help
    upload_2021-3-17_21-25-29.png
     
    Last edited: Mar 17, 2021
  10. MikeMnD

    MikeMnD

    Joined:
    Jan 17, 2014
    Posts:
    13
    I've got DOTweenAnimationfrom quite a time but mostly used from code.
    Today I tried to use the DOTweenAnimation componen, so:

    Code (CSharp):
    1.  
    2. private void Start()
    3. {
    4.     DOTweenAnimation spinAnimation = GetComponent<DOTweenAnimation>();
    5.     spinAnimation .onComplete.AddListener(OnSpinAnimationComplete);
    6. }
    7.  
    8. public void Spin()
    9. {
    10.      Debug.Log("spin animation start");
    11.     spinAnimation .DORestart();
    12.     spinAnimation.Play();
    13. }
    14.  
    15. public void OnSpinAnimationComplete()
    16. {
    17.   Debug.Log("spin animation complete");
    18. }
    19.  
    20.  

    The problem is when I call Spin() in runtime the Tween is not starting. If i test it trough the preview from the DOTweenAnimation component it works but the complete is not called.

    So is there some other way or some example of using the DOTweenAnimation component from code.
     
  11. SoupRound

    SoupRound

    Joined:
    Jul 15, 2014
    Posts:
    3
    Hey guys, I've encountered this problem, would be glad to have some help!

    Code (CSharp):
    1. transform.DORotate(new Vector3(0, 0, 10), 1f).SetLoops(-1, LoopType.Incremental).Play();
    Supposedly it continuously rotate 10 degree every second, but it behaves like LoopType.Restart

    I also tried DOLocalRotate, but it gives the same undesired result.
     
  12. FuguFirecracker

    FuguFirecracker

    Joined:
    Sep 20, 2011
    Posts:
    419
    watch out for onComplete vs OnComplete
     
  13. flashframe

    flashframe

    Joined:
    Feb 10, 2015
    Posts:
    797
    You need to set the rotation mode to WorldAxisAdd,

    Code (CSharp):
    1. transform.DORotate(new Vector3(0, 0, 10), 1f, RotateMode.WorldAxisAdd).SetLoops(-1, LoopType.Incremental).Play();
     
  14. SoupRound

    SoupRound

    Joined:
    Jul 15, 2014
    Posts:
    3
    Double checked, this doesn't work either. What might I be missing on?
     
  15. flashframe

    flashframe

    Joined:
    Feb 10, 2015
    Posts:
    797
    Try RotateMode.LocalAxisAdd ?
     
  16. BebopTune

    BebopTune

    Joined:
    Apr 7, 2019
    Posts:
    25
    Hello, DoPunchPosition not allow other tween to perform in sequence. Anyone Know why and what to do?

    Code (CSharp):
    1.  
    2.     seq = DOTween.Sequence();
    3.         seq.Append(transform.DOMove(pos, duration));
    4.         seq.Join(transform.DOPunchPosition(Vector3.right, duration, 5, 1));
    DoMove not work in this case just Punch works.
     
  17. SoupRound

    SoupRound

    Joined:
    Jul 15, 2014
    Posts:
    3
    That doesn't help either
     
  18. outpost31d

    outpost31d

    Joined:
    Feb 1, 2019
    Posts:
    11
    Hi, I am using DoTweenPro to have a platform move up, rotate then move back to its original position. I am using an OnCollision to activate the DOTweenPath (move platform up)--> OnComplete--> DoTweenAnimation.DoPlay (rotate)---> OnComplete--> DoTweenPath.DoPlayBackwards (return platform to original position). It works the first time but problem is when I do another collision it will not start again, any suggestions? thnx
    vid here https://www.loom.com/share/dd02cd8dd351425f9ab4dd3bd8411c57?t=14
     
    Last edited: Apr 5, 2021
  19. Morphus74

    Morphus74

    Joined:
    Jun 12, 2018
    Posts:
    174
    Is DoTween still supported, been almost a year since an update? Thank
     
  20. Zebbi

    Zebbi

    Joined:
    Jan 17, 2017
    Posts:
    521
    This was super helpful for using OnComplete, I wish it was stickied :p
     
  21. el_Guero

    el_Guero

    Joined:
    Sep 15, 2017
    Posts:
    185
    Not sure if this is still actively supported since I didn't get any reply writing through the contact form but I give it a go, maybe someone else can help me?

    I have a problem with DOTween having to adjust its capacity when playing levels in my mobile game. I’m sure I have something set up the wrong way because the game doesn’t ‘expand’ or get more complex over time, meaning there should always be the same amount of tweens used more or less.

    Screen Shot 2021-04-06 at 12.09.30.png

    I unfortunately do not understand why this is happening since the tweens are automatically killed. Could you help me to figure out why this is happening or where I should be looking?

    I might not be understanding the core logic of how to use the tweens? Or is this behavior normal?

    Btw, I'm using Playmaker actions to use tweens (if that makes a difference).
     
  22. AlejMC

    AlejMC

    Joined:
    Oct 15, 2013
    Posts:
    149
    Hello!
    Had a suggestion regarding DOTweenAnimation and Fade. When using fade on an Image that also has a CanvasGroup, it allows to select which element to target: the Image itself or the CanvasGroup.
    For Text though, it doesn't really offer that option... it would be quite useful since sometimes text gets complicated with rich text coloring and a global CanvasGroup for fading it all works great.

    Workaround: currently I'm just parenting that 'complex rich text' to a parent that holds the canvas group but since the functionality is already there for Image maybe it makes sense to expand it to other UI elements.
    My .00002 cents.
     
  23. FuguFirecracker

    FuguFirecracker

    Joined:
    Sep 20, 2011
    Posts:
    419
    I suspect that you are creating tweens in an Update(); Don't do that.

    No.

    Me too

    Sorry, I've never used Playmaker so I cannot provide any further assistance. Perhaps the Playmaker forum will be of more help. I do believe that there are more Playmaker people what use DoTween than DoTween people what use Playmaker.*

    *I have no statistics to back this up this assertion.
     
  24. FuguFirecracker

    FuguFirecracker

    Joined:
    Sep 20, 2011
    Posts:
    419
    That code does exactly what it says on the tin. Are you SURE it behaves like LoopType.Restart ?
    If you change the LoopType to LoopType.Restart it does the exact same thing !?

    You haven't confused the EaseOut behaviour at the end of of every 10° increment ?
    Setting the Ease makes no difference?
    Code (CSharp):
    1.  
    2. transform.DORotate(new Vector3(0, 0, 45), 1f)
    3.     .SetLoops(-1, LoopType.Incremental)
    4.     .SetEase(Ease.Linear)
    5.     .Play();
    If is IS restarting, you're doing something to restart it somewhere else in your code .. and you haven't provided enough information, beacuse:

    Code (CSharp):
    1.  
    2. using DG.Tweening;
    3. using UnityEngine;
    4.  
    5. public class Spinnerella : MonoBehaviour
    6. {
    7.     private void Start()
    8.     {
    9.         transform.DORotate(new Vector3(0, 0, 10), 1f)
    10.            .SetLoops(-1, LoopType.Incremental)
    11.            .SetEase(Ease.Linear)
    12.            .Play();
    13.     }
    14.  
    15. }
    16.  
    No issues whatsoever
     
  25. el_Guero

    el_Guero

    Joined:
    Sep 15, 2017
    Posts:
    185
    There is no direct way to use playmaker actions in update method. Only if there is a specific setting for this which dotween actions do not have.

    I think I found the culprit though. I have rotating coins in my game and to rotate them they are using dotween. I now got rid of the tween for this purpose and the error message is gone.

    What I did with those rotating coins is that they were in a prefab and that prefab got spawned with PoolBoss inside a levelsection prefab. Maybe it created like this continuously a copy of the tween for the coins instead of re-using it or killing it? Does something like this ring a bell or make sense? Coins within a prefab that gets spawned and despawned continously, each coin running a playmaker action with that rotating tween applied...
     
  26. FuguFirecracker

    FuguFirecracker

    Joined:
    Sep 20, 2011
    Posts:
    419
    Sadly, my dude, nobody is able to tell you what PoolBoss is doing to your Playmaker actions that is confounding DoTween ... Not without looking through your project, that is.

    I must tell you, however, that 9 times out of 10 * when DoTween starts maxing out the tweens like that, it's because they are being created ad nauseum due to user error. The usual culprit is spamming tweens out in an Update loop; Whether you're aware of it or not. Who knows what's going on within the black boxes of PlayMaker and PoolBoss.. Certainly not I.

    You can send me a dm [click ma name and start a conversation ] if you need someone to look at your project.


    *not an actual statistic
     
    el_Guero likes this.
  27. auau52

    auau52

    Joined:
    Apr 3, 2020
    Posts:
    16
    Hello, I love DOTween and I purchased Pro.
    Handle all animations in inspector via DOTweenAnimation is nice. But I have a problem.

    I'm using two animations for one object; for showing/hiding animation.
    I want different Ease for each animation, so PlayBackward was not an option.

    When I set type of showing animation FROM, hiding animation (which is TO type) doesn't playing.
    Using FROM/TO type animation at same object is invalid? If then, what is best practice for Show/Hide animations?

    Thanks in advance!

    upload_2021-4-13_14-52-20.png
     
  28. FlightOfOne

    FlightOfOne

    Joined:
    Aug 1, 2014
    Posts:
    668
    Hello, Am I supposed to get GC allocation with DoTween?

    below is what I read on the website, how do I do this?
    caches and reuses stuff automatically (if you want) and doesn't generate any useless GC allocations


    This is what I am running:
    tween = hand.DOLocalRotate(handEuler, movementTime, RotateMode.FastBeyond360);


    How do I eliminate gc? Thanks!
     
  29. polypixeluk

    polypixeluk

    Joined:
    Jul 18, 2020
    Posts:
    53
    I can't for the life of me workout why I can't kill a sequence. Can anyone tell me what I'm doing wrong?

    Code (CSharp):
    1. Sequence sequence;
    2.  
    3. private void OnEnable()
    4. {
    5. sequence = DOTween.Sequence();
    6. }
    7.  
    8. private void Update()
    9.     {
    10.         if (Input.GetKeyDown(KeyCode.K))
    11.         {
    12.             Debug.Log("Kill tween!");
    13.             //sequence.Kill(true);
    14.             //sequence.Kill();
    15.             DOTween.Kill(sequence);
    16.         }
    17.  
    18.     }
    19.  
    20. public IEnumerator UpdateCameraValues(float delay, float duration)
    21.     {
    22.         yield return new WaitForSeconds(delay);
    23.         sequence.Append(DOTween.To(() => currentPerc, x => currentPerc = x, targetPerc, duration).SetEase(Ease.OutExpo));
    24.     }
     
  30. flashframe

    flashframe

    Joined:
    Feb 10, 2015
    Posts:
    797
    Since you have a reference to the Sequence, you can kill it directly:

    Code (CSharp):
    1. sequence.Kill();
     
  31. FuguFirecracker

    FuguFirecracker

    Joined:
    Sep 20, 2011
    Posts:
    419
    I think they tried this - as as can be seen in the commented-out code.

    My guess is: You're killing the sequence, but not the coroutine what is continually appending to the sequence.
    Just a guess.

    How often is UpdateCameraValues being called? Updating DoTween in this manner is not ideal. One should not have to start an Coroutine to control DoTween. Do have a look at DoTween's OnUpdate() callback
     
    flashframe likes this.
  32. unity_1matheusguilherme1

    unity_1matheusguilherme1

    Joined:
    May 21, 2019
    Posts:
    1
    Is DoTween working with unity 2021 versions?
     
  33. polypixeluk

    polypixeluk

    Joined:
    Jul 18, 2020
    Posts:
    53
    I'm not calling UpdateCameraValues() on update. I use the coroutine for the delay at the start. But all the function does is wait then start tweening currentValue to targetValue.

    In the update I check to see if the currentValue var is different from the values on the camera and if they are I update them. Like this:

    Code (CSharp):
    1.  private void Update()
    2.     {
    3.         //Update FOV
    4.         if (playerVcam.m_Lens.FieldOfView != fovCurve.Evaluate(currentPerc))
    5.         {
    6.             playerVcam.m_Lens.FieldOfView = fovCurve.Evaluate(currentPerc);
    7.         }
    8.         //Update Cam transform
    9.         if (transposer.m_FollowOffset.y != offsetCurve.Evaluate(currentPerc))
    10.         {
    11.             transposer.m_FollowOffset.y = offsetCurve.Evaluate(currentPerc);
    12.         }
    13.         //Update aim target
    14.         if (composer.m_TrackedObjectOffset.y != aimCurve.Evaluate(currentPerc))
    15.         {
    16.             composer.m_TrackedObjectOffset.y = aimCurve.Evaluate(currentPerc);
    17.         }
    18.     }

    But just to be sure, you're saying there is nothing wrong with the following method of killing the sequence in this context?

    Code (CSharp):
    1.  sequence.Kill();
    If that's the case then at least I know where NOT to look for solutions. :)
     
    Last edited: Apr 23, 2021
  34. FuguFirecracker

    FuguFirecracker

    Joined:
    Sep 20, 2011
    Posts:
    419
    Did you know that you can chain a Delay() method onto your sequence?
    This eliminates the need to spin up a couroutine just for a delay.

    And sequence.Kill() should kill that tween. If not... you're doing something somewhere.

    EDIT:
    Do you really need a sequence? It appears you're only doing 1 tween.

    Heres a simple tween with delay and onupdate that kills itself
    Try it out see that it works. See if you can apply the concept to your own code.
    Code (CSharp):
    1. using DG.Tweening;
    2. using DG.Tweening.Core;
    3. using DG.Tweening.Plugins.Options;
    4. using UnityEngine;
    5.  
    6. public class KillKillKill : MonoBehaviour
    7. {
    8.  
    9.     void Start()
    10.     {
    11.         DoThatMoveYouDo(1.2f, 10f);
    12.     }
    13.  
    14.     private void DoThatMoveYouDo(float delay, float duration)
    15.     {
    16.         TweenerCore<Vector3, Vector3, VectorOptions> myTween = null; // gotta initialize
    17.                                                                      // so can call the local variable
    18.                                                                      // in OnUpdate
    19.        
    20.         myTween = transform.DOMoveX(10, duration)
    21.             .SetDelay(delay)
    22.             .SetEase(Ease.OutExpo)
    23.             .OnUpdate(() =>
    24.             {
    25.                 if (Input.GetKeyDown(KeyCode.K))
    26.                 {
    27.                     myTween.Kill();
    28.                 }
    29.             });
    30.     }
    31. }
    32.  
     
    Last edited: Apr 24, 2021
    polypixeluk likes this.
  35. farazk86

    farazk86

    Joined:
    May 31, 2017
    Posts:
    195
    Hi all,

    bought the dotween pro, but apparently it seems to be abandoned by the developer as there is no documentation for the pro asset. :(

    I want to run both these animations in parallel. Is this something I can do?

    image_2021-04-26_120235.png
     
  36. MinamLEE

    MinamLEE

    Joined:
    Jan 19, 2020
    Posts:
    2
    Hi Farazk,
    I am a DOTween beginer but what's the matter ? both tween will autoplay on start I think.
     
  37. MinamLEE

    MinamLEE

    Joined:
    Jan 19, 2020
    Posts:
    2
    I have a problem to restart a tween. It's a shake position. It's playing fine and I can restart it. But on restart it will shake using the previous local position.

    Is there a way to
    1 play a tween,
    2 move the gameobject, do some game stuff
    3 restart this tween but using current local position (not the local position of step 1)

    Thank you for your help
     
  38. polypixeluk

    polypixeluk

    Joined:
    Jul 18, 2020
    Posts:
    53
    For some reason I'd only ever really controlled tweens as sequences. But controlling it as a tween , using the tweener settings/call backs and ditching the coroutine is working much nicer. Thank you!
     
    FuguFirecracker likes this.
  39. FuguFirecracker

    FuguFirecracker

    Joined:
    Sep 20, 2011
    Posts:
    419
    Use parameters.
    Post some code, I'll give you some pointers.
    Post pics of the GUI, and I'll tell you to learn how to code ;) Just kidding [ not really ]
     
  40. Nefisto

    Nefisto

    Joined:
    Sep 17, 2014
    Posts:
    333
    I'm using dotween to make an yoyo behavior between values invoking something after each step, but I figured out that dotween counting time is strange so I make this simple example to show. What am I doing wrong?

    Example:
    example.gif

    Code:
    Code (CSharp):
    1. public class Test : MonoBehaviour
    2. {
    3.     public float dotweenTimer = 0f;
    4.     public float manualTimer = 0f;
    5.  
    6.     private void Start()
    7.     {
    8.         DOTween
    9.             .To(() => dotweenTimer, (x) => dotweenTimer = x, 1000f, 1000f)
    10.             .SetLoops(-1);
    11.  
    12.         StartCoroutine(MyTimer());
    13.     }
    14.  
    15.     private IEnumerator MyTimer()
    16.     {
    17.         while (true)
    18.         {
    19.             manualTimer += Time.deltaTime;
    20.  
    21.             yield return null;
    22.         }
    23.     }
    24. }
     
  41. FuguFirecracker

    FuguFirecracker

    Joined:
    Sep 20, 2011
    Posts:
    419
    your "dotweenTimer" is a timer in name only. Might as well call it "dotweenPotatoPeeler" and then marvel as to why your potatoes remain unpeeled.

    It's not a timer, it's a tweener, and unless you've set your Ease values to Linear in the setup [ or append .SetEase() ], it's gonna start fast and end slow.

    If you want to use time, you need to reference time...
    Take a look at useSmoothDeltaTime and .SetSpeedBased()

    Docs
     
    Last edited: Apr 27, 2021
  42. farazk86

    farazk86

    Joined:
    May 31, 2017
    Posts:
    195
    image_2021-04-28_001038.png

    Can anyone please tell me how can I call these tween animations from script? Like I have a script attached to this gameObject. How do I reference these animations and how do I play them?

    Thanks
     
  43. FuguFirecracker

    FuguFirecracker

    Joined:
    Sep 20, 2011
    Posts:
    419
    Not ignoring your pleas for help; I've just never even once looked at the GUI.

    This should help
     
    farazk86 likes this.
  44. Nefisto

    Nefisto

    Joined:
    Sep 17, 2014
    Posts:
    333
    First of all thanks for your help

    I didn't really get this help, SetSpeed only make my value go crazy (below image) if I call with the default value and stay the same if change the parameter to false and useSmoothDeltaTime does not make sense for me, what I want here isn`t change the update methods, also it didn't solve the problem
    example.gif


    BUT inside SetSpeed description it appears "NOTE: if you want your speed to be constant, also set the ease to Ease.Linear." and this makes the thing happen in the way that I want
    example2.gif

    So it is solved, but only to make sure that I understood it right, can you clarify to me two things?

    First:
    Are you saying that if I tell a tween to increase from 1 to 100 in 100 seconds the numbers will not increase in one per second? Because this is the behavior that I've been expecting

    Second:
    Ease.Linear isn't the default kind of ease used in tweens?

    [EDIT] As soon as I posted it I tried to change the default ease type and then found the answer to the two questions
    upload_2021-4-28_6-35-33.png

    Default isn't linear, so this will make counter things count in a "strange" way


    [EDIT 2]
    But this gimme a new question. I haven't seen changes when I try to change the defaultEaseType. So my question is:
    upload_2021-4-28_6-40-0.png
    It is possible to change this default type? Because as it returns the ease and I haven't seen changes when I equal this to a new ease type, it makes me think that this is somekind of "read only" thing.
     
    Last edited: Apr 28, 2021
  45. FuguFirecracker

    FuguFirecracker

    Joined:
    Sep 20, 2011
    Posts:
    419
    Me: Look at SetSpeedBased
    You: That didn't help
    Also You: Looking at SetSpeedBased solved my problem.
    Me: o_O


    By default, yes, that is what I am saying.
    It isn't.

    Tools > Demigiant > DoTween Utility Panel
    dtd.png
     
  46. Nefisto

    Nefisto

    Joined:
    Sep 17, 2014
    Posts:
    333
    You're right hehe this was funny, but I mean, it isn't the SetSpeedBased that solves the problem, is a note that exists in the description.

    Jokes apart, thanks for your help
     
    FuguFirecracker likes this.
  47. farazk86

    farazk86

    Joined:
    May 31, 2017
    Posts:
    195
    Thank you. I tried getting tweens on the current game object using:

    Code (CSharp):
    1. private DOTweenAnimation animationTweens;
    2.     private List<Tween> deathTweens;
    3.  
    4.     void Start()
    5.     {
    6.         animationTweens = GetComponent<DOTweenAnimation>();
    7.         deathTweens = animationTweens.GetTweens();
    8.         print(deathTweens);
    9.     }
    But I'm getting the error: "Object reference not set to an instance of an object"

    Is this the correct way to go about this?
     
  48. FuguFirecracker

    FuguFirecracker

    Joined:
    Sep 20, 2011
    Posts:
    419
    Is there a DOTween animation also attached to the gameObject upon which this script is attached?
    If not, that would account for the Object Reference error. The gameObject itself ... not on child objects; Otherwise you would need to use GetComponentInChildren<>()



    This simple code will get the tweens on the same object ... so you're real close with the code you posted.
    Code (CSharp):
    1. using DG.Tweening;
    2. using UnityEngine;
    3.  
    4. public class ARealTweenGetter : MonoBehaviour
    5. {
    6. void Start()
    7.     {
    8.         var tweens = GetComponent<DOTweenAnimation>().GetTweens();
    9.         foreach (var tween in tweens) { Debug.Log(tween); }
    10.     }
    11.  
    12. }
    13.  
    if you want to find tweens on another game object, you'll need to use public fields and you can drag that gameObject into place with the inspector.

    Code (CSharp):
    1. using DG.Tweening;
    2. using UnityEngine;
    3.  
    4. public class ARealTweenGetter : MonoBehaviour
    5. {
    6.     public DOTweenAnimation TheTweensITellsYa; // Set in inspector
    7.  
    8.     void Start()
    9.     {
    10.         foreach (var tween in TheTweensITellsYa.GetTweens())
    11.         {
    12.             Debug.Log(tween);
    13.         }
    14.     }
    15. }
     
    farazk86 likes this.
  49. tnaseem

    tnaseem

    Joined:
    Oct 23, 2009
    Posts:
    149
    As others have already mentioned in this thread, I'm getting the following error each time I exit Play Mode (I have turned on Verbose logging, but no other information is provided:

    Screenshot 2021-04-29 at 07.37.07 PM.png

    This is on Windows 10, Unity 2020.3.5f1, DoTween Pro 1.0.244.

    All I have done is to create a DoTween Path, in the Inspector, for a simple animation, which runs automatically and does an AutoKill (supposedly - see update below!).

    The one thing I have noticed though is that when I delete this Prefab with the tween, the path line stays in the editor scene view. See below:

    Original Prefab (screen) with the animation:
    Screenshot 2021-04-29 at 07.22.11 PM.png

    This performs the animation of a small ship flying to the planet. This entire prefab is then deleted, and another one instantiated (new screen below), but as you can see, the path is still visible in the scene editor view:

    Screenshot 2021-04-29 at 07.12.57 PM.png

    Not sure if this is related to the error as the error happens even if I quit the Play mode when the first prefab is still active.

    If anyone has any clues, I'd be grateful for any pointers!

    (By the way, it has nothing to do with deleting and instantiating the prefabs, as it happens regardless. I've tested it with just the path animation prefab on its own).

    UPDATE
    It seems that if I kill the tween myself, in my script, when I'm done with it, it resolves the problem. Seems the AutoKill doesn't appear to kill the tween in my case.
     
    Last edited: Apr 29, 2021
  50. AlejMC

    AlejMC

    Joined:
    Oct 15, 2013
    Posts:
    149
    Hello there, just a few pointers on this as I kinda out of laziness do a lot of in-editor animation stuff: no compiling, can preview them directly (the main benefit for me), etc.
    There are a couple of ways to call the DOTweenAnimations for the GUI, however a couple of points:
    • I have had issues with DOTweens without ID, so in your stack of tweens make sure to have all of them with an ID. I usually go the extra mile and create a 'DOTween' empty game object and start adding 'DOTween animation groups' as children, putting the ID name the same as the gameobject's name that holds the DOTween's series of animations. These DOTweens instead of 'self', they target the specific objects it's supposed to animate.
      • DOTweenProposedHierarchy.png DOTweenSameIDs.png
    • If the DOTween is to be called manually and several times (one of the main benefits of DOTween, since the animations are basically "cached"), deselect both AutoPlay and AutoKill
    • Get the tweens themselves with script and call the function you want (PlayForward, PlayBackwards, Restart, etc) but on ONLY one of them, this will make it trigger all the ones in the object (I think this is undocumented, I just found out). The main DOTweenAnimation gameobject component has an interface for that.
    • Or use Unity Events (may favourite way as it allows for binding/un-binding in-editor) and drag and drop the game object and call the functions there. For example, unity 'buttons' have an event 'OnClick' ready to use, so you can call the animation every time the button is pressed
      • DOTweenAssignmentViaUnityEvents.png
    I use this so much that I went ahead and did wrapper managers, tools, etc around it but all based on the series of bullet points above. It's basically to get around the somewhat UX harsh nature of the GUI Inspector, but make no mistake, I find it really powerful and quick to do playful and fancy animations with ONLY the GUI version and very minor "High Level" scripts that call specific UnityEvents at the right time.
    DOTweenManagerAndEditorWindows.png

    Hope this all helps.
    Edit: typos and somewhat unclear phrase. Also, make sure to click on the tiny images, put them as thumbnails for the sake of not making it a huge post.
     
    farazk86 likes this.