Search Unity

DOTween (HOTween v2), a Unity tween engine

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

  1. Klausology

    Klausology

    Joined:
    Aug 29, 2017
    Posts:
    131
    Hello developer. I recently bought your DOtween pro asset and am absolutely loving it! I notice that some tween shortcut methods produce a strange error in the Rider editor:

    Screenshot 2020-11-26 at 12.40.21 AM.png

    Here you can see that "DOScale" has no errors but "DOFillAmount" has a cannot resolve symbol error. The strange thing is that there are no error consoles in Unity's editor itself and the code executes fine. The error appears to be just within the Rider's editor. Could I be missing some crucial step in getting this to work properly? Thank you for your assistance!
     
  2. francismoy

    francismoy

    Joined:
    Jul 5, 2017
    Posts:
    46
    Hi!

    I bought DoTween Pro and I'm experimenting with TextMesh Pro tweens.

    The problem I'm facing is the following:

    I want to curve the text, and I can do it easily with a script, provided by the TMPro developer, that transforms the text vertices. However, when I apply a simple per-character scale tween to this curved text (using DOTweenTMPAnimator), the curve is lost.

    I've tracked down the reason to be a call to ForceMeshUpdate(true) in the Refresh() method of DOTweenTextMeshPro.cs. That is, if I comment that line out, the tween is correctly applied to the curved text.

    My question is: would it be safe to selectively call that line with a flag passed to Refresh() (in turn passed to the DOTweenTMPAnimator constructor) called resetTransformations? Something like this:

    DOTweenTextMeshPro.cs:

    Code (CSharp):
    1. public DOTweenTMPAnimator(TMP_Text target, bool resetTransformations)
    2. {
    3.     ...
    4.     Refresh(resetTransformations)
    5.     ...
    6. }
    7.  
    8. public void Refresh(bool resetTransformations)
    9. {
    10.     ...
    11.  
    12.     if (resetTransformations)
    13.     {
    14.         target.ForceMeshUpdate(true);  
    15.     }
    16.  
    17.     ...
    18. }
    19.  
     
    Last edited: Nov 27, 2020
  3. Xarbrough

    Xarbrough

    Joined:
    Dec 11, 2014
    Posts:
    1,188
    Hey fellow DoTween users, I'm looking for a workaround to the following issue: https://github.com/Demigiant/dotween/issues/400

    When calling Complete from within another tween's callback, the first tweens onComplete event is not invoked. There's some kind of safety check within DOTween that might prevent recursion or something, but I'd like to suggest changing this behaviour. For the moment, I'm trying to find a way to make this work when two tweens interact. Any ideas? Thanks!
     
  4. dyfer

    dyfer

    Joined:
    May 6, 2013
    Posts:
    6
    Hey hey,

    Is it just me or Unity 2019.4.15 LTS and DOTween Pro Path editor are not working very well together ?

     
  5. pgrenon_me

    pgrenon_me

    Joined:
    May 30, 2019
    Posts:
    2
    Does anyone know if it is possible to use the DoTweenAnimation component to create sequences like in this example:
    1. move forward by 20;
    2. move up by 10;
    3. play number 2 backwards
    4. play number 1 backwards
    and then repeat from number 1.

    If it is, what is the setup to achieve this?
     
  6. lorewap3

    lorewap3

    Joined:
    Jun 24, 2020
    Posts:
    58
    Greetings!

    I'm trying to find documentation regarding the easing functions. I just want to use them, but how to use them isn't mentioned anywhere. I'm animation based on musical beat durations and I already have that system in place so I don't need to create tweens. I just want to use those beat durations and apply the various easing functions to the variables I'm animating.

    I mean it didn't take 2 seconds to find another easing library online, but why would I duplicate that code when DOTween obviously already has them?

    Thanks,
    Will
     
  7. flashframe

    flashframe

    Joined:
    Feb 10, 2015
    Posts:
    798
    Have you tried:

    SetLoops(-1, LoopType.Yoyo)
     
  8. flashframe

    flashframe

    Joined:
    Feb 10, 2015
    Posts:
    798
    ertrgvfdfcdsxswesqa
    http://dotween.demigiant.com/documentation.php#virtualTweens

    static float DOVirtual.EasedValue(float from, float to, float lifetimePercentage, Ease easeType \ AnimationCurve animCurve)
     
  9. SavaliyaNiraj

    SavaliyaNiraj

    Joined:
    Dec 25, 2018
    Posts:
    1
    Can you please make example of move object to target with swing in x axes or in other word move object to target with in curve shape
     
  10. alterra_br

    alterra_br

    Joined:
    Mar 29, 2019
    Posts:
    5
    Hi!
    When I hide game in Android (app lost focus), and after show it back all my TMPro UI text are disappeared.
    Using DOCount and DOText tweens in sequence.
    DOTween 1.2.420
    DOTween Pro 1.0.244
    Any advice?
     
  11. urbemAngeli

    urbemAngeli

    Joined:
    May 12, 2017
    Posts:
    61
    What method should i call to update my animation manually?
     

    Attached Files:

  12. flashframe

    flashframe

    Joined:
    Feb 10, 2015
    Posts:
    798
    urbemAngeli likes this.
  13. urbemAngeli

    urbemAngeli

    Joined:
    May 12, 2017
    Posts:
    61
    Thank you, I have been trying to find a similar method for a long time.
     
    flashframe likes this.
  14. urbemAngeli

    urbemAngeli

    Joined:
    May 12, 2017
    Posts:
    61
    I am animating the movement of a physical object, when I call DOTween.ManualUpdate (float deltaTime, float unscaledDeltaTime) the position update occurs on the next FixedUpdate () frame. Can I at the time of manual update (after I have already updated) immediately in the current frame find out the new position of my object?
     
  15. earsay

    earsay

    Joined:
    Dec 23, 2017
    Posts:
    5
    Hi guys,

    I have Addressables issue if you ever used it.

    I have prefabs that has tweens in it. Whenever I try to build these prefabs with tweens not commented out, I get this errors.

    Assets\Scripts\Spawnables\Road.cs(13,19): error CS0012: The type 'Quaternion' is defined in an assembly that is not referenced. You must add a reference to assembly 'UnityEngine, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'.

    Assets\Scripts\GUIContollers\TabOpener.cs(52,25): error CS0012: The type 'Vector3' is defined in an assembly that is not referenced. You must add a reference to assembly 'UnityEngine, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'.

    Failed to compile player scripts
    UnityEditor.GenericMenu:CatchMenu(Object, String[], Int32)

    SBP ErrorError
    UnityEditor.GenericMenu:CatchMenu(Object, String[], Int32)


    Before this error I put the Modules folder in Editor folder because I was getting 742 variant of this error below.

    Assets\Plugins\Demigiant\DOTween\Modules\DOTweenModuleUI.cs(28,57): error CS0012: The type 'Vector2' is defined in an assembly that is not referenced. You must add a reference to assembly 'UnityEngine, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'.

    Variants erros changes from 'Vector3' to 'Color' to any other datatype. I tried on my mac too, same thing happened.


    Do you have any idea what is the cause of this. I dont want to switch back to regular prefabs :) thanks..



     
  16. adityadroid29

    adityadroid29

    Joined:
    Sep 4, 2020
    Posts:
    3
    Hi Guys,
    I am pretty new to DoTween and currently trying this very simple task using DoTween to make my object follow other object, my goal is that I have an Target and just gets its LocalPosition set directly by Target.LocalPosition = Position now i want my second object to use DoTween to lerp to Target, simple. For this I made a method and this method could be called several times before the Tween could be completed, below is the code/method I am using for this

    Code (CSharp):
    1. public void SetPosition(Vector3 Position)
    2.     {
    3.         Target.localPosition = Position;
    4.         if (_canJump)
    5.         {
    6.             _canJump = false;
    7.             Tweener tnr = transform.parent.DOLocalMove(Target.localPosition, 0.3f);
    8.             tnr.OnUpdate(() => { tnr.ChangeEndValue(Target.localPosition); });
    9.             tnr.OnComplete(() => { _canJump = true; });
    10.         }
    11.     }
    There is no movement in my object using above code as is but if I remove the OnUpdate Callback then i get some movement but its all buggy. I have google several times, seen many tutorials about DoTween but no luck, please do let me knopw what is wrong with above code.

    If you want to know what exactly i am trying to do is that I have Six objects that will use DoTween and they are running in straight line and when I give some Input they start making some patterns like human tower, pyramid etc, so for this I tried setting the localposition of Target directly by snapping it to its desired position and then tweening my actual visible object to that position but as you know I have several patterns that are based on Drag input so this tween and target poisition snapping could happen for several times in quick sessions that is why I am using that OnUpdate Callback so that whenever the Target changes its position before the completion of current tween, it should just follow that new position. Hope I made it all easy to understand.
     
  17. battman00

    battman00

    Joined:
    Mar 28, 2020
    Posts:
    10
    Sorry as I'm sure this has already been asked, but I wasn't able to find an answer...

    I'm trying to flash the enemy white whenever they're hit, but if they're hit in quick session the "From()" call doesn't return the original value and enemy stays white. Is there a easy way to do this without Sequences?


    _renderer.material.DOFloat(0.5f, "_FlashAmount", 0.4f).From();



    EDIT:
    I was able to get expected results with OnComplete(), is it more efficent to use OnComplete or Sequences?


    _renderer.material.DOFloat(0.5f, "_FlashAmount", 0.2f).OnComplete(()=> _renderer.material.DOFloat(0f, "_FlashAmount", 0.2f));
     
    Last edited: Dec 15, 2020
  18. Ziplock9000

    Ziplock9000

    Joined:
    Jan 26, 2016
    Posts:
    360
    How do I set a looping animation's starting phase?

    I have the following tween that moves a coin up and down:

    transform.DOMoveY(0.75f, 1f,false).SetLoops(-1, LoopType.Yoyo)

    The problem is that I have this on a lot of coins that all get instantiated at the same time, and I want each animation to be slightly offset so that they are all out of sync.
    Having a delay won't work as that will make some of the coins static before they start moving. What I need is a way to set the phase of the animation like so:

    transform.DOMoveY(0.75f, 1f,false).SetLoops(-1, LoopType.Yoyo).setPhase(UnityEngine.Random.value)

    This will then set the phase (the point in the animation) where it starts from. How do I do this?
     
  19. flashframe

    flashframe

    Joined:
    Feb 10, 2015
    Posts:
    798
    Try Goto

    http://dotween.demigiant.com/documentation.php#controls

    GotoAll/Goto(float to, bool andPlay = false)
     
    Ziplock9000 likes this.
  20. Emme73

    Emme73

    Joined:
    Jan 24, 2013
    Posts:
    25
    Hello, I bet this is an easy one, I am currently in preproduction of a vertical shoot em up, and I would like to use DoTween Pro for the enemy movement patters. For this I wonder if I can create a path, have an enemy follow that path, and when it reaches the END of the path it yoyos between the last two path points (path is not closed). So that I can make the enemy object fly into the scene, do a little looping and then arrive at its "end pattern" where it just moves left an right.
     
  21. flashframe

    flashframe

    Joined:
    Feb 10, 2015
    Posts:
    798
    http://dotween.demigiant.com/documentation.php#options

     
  22. patrickjansendesign

    patrickjansendesign

    Joined:
    Jan 21, 2020
    Posts:
    48
    so... from a bit of testing i figured, having multiple OnUpdates and OnCompletes for 1 sequence is not possible??

    from test below only the later 2 execute


    void Start()
    {
    float t = 2f;
    Sequence T = DOTween.Sequence();
    T
    .Append(transform.DOJump(new Vector3(0,0,0), 1.5f, 1, t, false))
    .OnUpdate(() => OnUpdate1())
    .AppendCallback(() => print("counter = " + counter + " DOJump AppendCallback"))
    .OnComplete(() => print("counter = " + counter + " DOJump OnComplete"))
    .Append(transform.DOMove(new Vector3(1,2,3), t))
    .OnUpdate(() => OnUpdate2())
    .AppendCallback(() => print("counter = " + counter + " DOMove AppendCallback"))
    .OnComplete(() => print("counter = " + counter + " DOMove OnComplete"))
    ;
    }
    void OnUpdate1()
    {
    counter++;
    print("counter = " + counter + " DOJump OnUpdate");
    }
    void OnUpdate2()
    {
    counter++;
    print("counter = " + counter + " DOMove OnUpdate");
    }
     
  23. patrickjansendesign

    patrickjansendesign

    Joined:
    Jan 21, 2020
    Posts:
    48
    so only 1 OnComplete and 1 OnUpdate per sequence possible? right?

    Should i stitch sequences together if i need different onupdates and different oncompletes for a Append DOMove - append DOJump - append DORotate sequence?
     
  24. patrickjansendesign

    patrickjansendesign

    Joined:
    Jan 21, 2020
    Posts:
    48
    by the way, i get the expected onUpdate during the tween process but i also get an additional/final OnUpdate AFTER AppendCallback.... :(

    My app functionality has 3 booleans to turn 3 gameobject animation effects on or off and i want to use the onupdates to set one of them to true and when done set it back to false, and that for 3 tweens in sequence (move-jump-rotate) on my main object. I tried using appendcallback to set booleans back to false but the last OnUpdate fires right after the appendcallback basically undoing that.
     
  25. bobueland

    bobueland

    Joined:
    Sep 27, 2019
    Posts:
    19
    Hi Folks,

    For anybody interested I have made a tutorial for DoTween, the free version, which you can find on YouTube at (Extreme Explaining Dotween)



    Cheers
     
    Last edited: Jan 6, 2021
    ledshok likes this.
  26. risikoruk3678

    risikoruk3678

    Joined:
    Dec 21, 2020
    Posts:
    1
    Any idea why after I call DOTween.PlayingTweens(); and cycle them in a foreach cycle, using tween.id returns NULL? The tween definitely exists because if I use PathGetPoint I get a result
     
  27. spirachi77

    spirachi77

    Joined:
    Sep 26, 2017
    Posts:
    17
    I'm trying to destroy a gameobject on a tweens completions, I tried this:

    public void KillActor(){
    actorTweens.AppendCallback(()=>{Destroy(gameObject);});
    }

    but when I call KillActor, nothing happens, what should I do?
     
  28. bobueland

    bobueland

    Joined:
    Sep 27, 2019
    Posts:
    19
    Unity has
    public void RotateAround(Vector3 point, Vector3 axis, float angle);

    Is there a way to use DOtween to rotate around a point?

    (To put it inside a parent and rotate the parent is not a solution for me because it introduces all kind of problems, since I'm using the parent for other purposes.)

    Thanks
     
  29. FuguFirecracker

    FuguFirecracker

    Joined:
    Sep 20, 2011
    Posts:
    419
  30. ShadoX

    ShadoX

    Joined:
    Aug 25, 2010
    Posts:
    260
    Hi,

    Trying out the free DOTween and I seem to have an issue with the following code:
    Code (CSharp):
    1. transform.DOMoveZ(77f, 25f);
    I use variables for 77f and 25f, but that's rather irrelevant. My issue is that the DOMoveZ starts out with a seemingly constant speed and then slows down more and more during the last 5~10%, sometimes taking up to 5~10 if not more seconds to complete those last 5~10% of that the distance.

    That seems rather strange, since I had expected this to just work from start to end over the specified duration. Any ideas how to fix this ? I already checked online, but couldn't really find any solutions for this.

    Also - there's no other code running on that Transform that could slow it down. Tried out disabling any other scripts that might affect it, so it seems like some strange / unexpected behavior in DOTween :/
     
    Last edited: Dec 24, 2020
  31. FuguFirecracker

    FuguFirecracker

    Joined:
    Sep 20, 2011
    Posts:
    419
    ShadoX likes this.
  32. ShadoX

    ShadoX

    Joined:
    Aug 25, 2010
    Posts:
    260
    FuguFirecracker likes this.
  33. AlexanderMerk

    AlexanderMerk

    Joined:
    Nov 9, 2016
    Posts:
    16
    Hello everyone!

    I have a question.

    I am using dot twen pro.

    I have a gameobject with 2 tweens on it (see screenshot).

    1. 1 tween moving it to the right in 0 seconds

    2. 2 tween moving it back in X seconds

    Sometimes, in random cases, 1 tween starts working with delay for some frames (~1-4). How to fix that?


    Thank you in advance for your answers!


    P.S. I tried to remove delay from second tween and fire it by id in first one OnComplete

    P.S.S unity 2020.1.1.6f1

    Dotween pro 1.2.420

     
  34. DirtyHippy

    DirtyHippy

    Joined:
    Jul 17, 2012
    Posts:
    224
    Is there any way to get the Tweener context on callbacks like OnComplete? As far as I can tell the only way to do it right now is through a closure. Is this true? If so, why not change the callbacks to take the tweener that raised them as a parameter? Or more awfully, stash the caller tweener in a static member somewhere before the callback and clear it after? If one could get the tweener they could lookup context from it. Most of the time I have avoided this simply because most use cases include storing a single tweener as a member of a class, so the tweener is self-evident on a callback. But sometimes there are times when context is not inferable in this manner without a closure.

    Thanks!
     
  35. peeka

    peeka

    Joined:
    Dec 3, 2014
    Posts:
    113
    I ran into a weird bug, when my mobile game runs at 24 fps all tween works fine, but when it's ran at 60fps all the tween only tween about 10% the way, and stops in the middle.

    anyone have solved this problem before?
     
  36. breban1

    breban1

    Joined:
    Jun 7, 2016
    Posts:
    194
    Hoping you can help with something I am trying to do.

    I want a game object to scale up and down by .5 yoyo from ANY scale I set it to in code. Is that possible?

    Here is what I have in inspector:

    1) I am using the visual manager.
    2) Scale: duration=.5 Delay=0, loops=-1, type=yoyo, uniform scale, relative

    Screenshot of settings
    https://ibb.co/pnqjpNP

    Object has scale=1.0 in the inspector.

    It all scales up properly until I want to change the starting scale.

    For example, I set the scale to 2.0f in code. So, I want it to scale from 2.0f to 2.5f now. This is used for a tutorial system, so I do a bunch of these as the popup box moves around. It doesn't work right at all.

    I tried many combinations of SetActive(true/false) on the object, I tried DoRestart() ,I tried DoPlay(), etc. and nothing really works as I intend it to. I can't even keep track of all of the combinations I did to try to get this to work right.

    I'm assuming this is possible and I'm just missing something. Thanks.
     
  37. LuckyDavid

    LuckyDavid

    Joined:
    Jun 25, 2019
    Posts:
    3
    Is there any way to use rotate around and dotween at the same time? I basically just want something that has the smooth rotation of dotween and rotates from a certain point like rotate around.
     
  38. Kunalz

    Kunalz

    Joined:
    May 11, 2018
    Posts:
    25
    Hey guys I'm new to using tween but I am loving it, can anyone help me how to do certain things> I'd really appreciate it.

    1: How one could do a damage pop up effect with DOTween? I'm trying to get a effect where the damage displays as a pop up and slightly increases the font size up for a like half a second then back to original size then disappear.

    2. How does animated Sprite switching work?

    Thanks
     
  39. FuguFirecracker

    FuguFirecracker

    Joined:
    Sep 20, 2011
    Posts:
    419
    Answered on this very page.
    Ctrl+F and type: rotate
     
  40. LuckyDavid

    LuckyDavid

    Joined:
    Jun 25, 2019
    Posts:
    3
    I found a very odd solution to my problem by rotating an entirely different object with the pivot I want and then making the original object just equal that ones rotation and position while its rotating but since you cant quite find the actual position of an object if it has a different pivot I gave it a child object that had a normal pivot and put it at its center and used that to find the position and made the original objects position equal to that one.
     
    Last edited: Jan 10, 2021
  41. FuguFirecracker

    FuguFirecracker

    Joined:
    Sep 20, 2011
    Posts:
    419
    This rambling stream of consciousness is in dire need of more than one punctuation mark. ;)
     
    LateNighterDK likes this.
  42. starfoxy

    starfoxy

    Joined:
    Apr 24, 2016
    Posts:
    184
    Loving DoTween and have what is probably a really basic question.

    Code (CSharp):
    1. myTween.OnComplete(myCompleteFunction());
    I have the callback working and it properly runs myCompleteFunction().

    My question is, how can I pass my GameObject (the one that myTween is attached to) so that I can remove it when the tween completes?

    I tried this:

    Code (CSharp):
    1.  
    2.  
    3. Tween myTween = myThing.transform.DOMove(new Vector3(-5,-5,0), 1);
    4.  
    5. myTween.OnComplete(myCompleteFunction( this ));
    6.  
    7. void myCompleteFunction(GameObject theGameObject){
    8.         Destroy(theGameObject);
    9. }
    And it throws an error because 'this' isn't what should be passed.

    Can someone give me a nudge in the right direction here? Thank you kindly.
     
    Last edited: Jan 12, 2021
  43. flashframe

    flashframe

    Joined:
    Feb 10, 2015
    Posts:
    798
    Every tween has a "target" object. I think by default DOTween sets this to the transform of the game object you are tweening. So you should be able to pass myTween.target in your callback.
     
  44. iMobCoding

    iMobCoding

    Joined:
    Feb 13, 2017
    Posts:
    165
    You can simplify things pretty much:
    Code (CSharp):
    1. myThing.transform.DOMove(new Vector3(-5,-5,0), 1).OnComplete(() =>
    2. {
    3.     Destroy(myThing);
    4. });
    If you still want to pass to a new function then
    myCompleteFunction(myThing)
    . Of course, myThing should be a GameObject
     
    starfoxy and flashframe like this.
  45. flashframe

    flashframe

    Joined:
    Feb 10, 2015
    Posts:
    798
    Might want to destroy the object in OnKill instead - not sure if DOTween will complain?
     
    starfoxy likes this.
  46. FuguFirecracker

    FuguFirecracker

    Joined:
    Sep 20, 2011
    Posts:
    419
    To expand upon iMobCoding's valid answer ... And give you some explanation ...

    OnComplete expects a certain Method signature. When you attempt to pass arguments, you are not providing a Method with the correct parameters.

    In order to circumvent this, you need to wrap your method inside a method with the correct parameters.
    Lambdas to the rescue!

    ()=> is essentially an anonymous parameter-less method that returns void that fulfils the requirement of OnComplete and will execute the method contained therein. Whew, that was a mouthful.

    Code (CSharp):
    1. OnComplete(() => { Destroy(myThing); } );
     
    starfoxy likes this.
  47. starfoxy

    starfoxy

    Joined:
    Apr 24, 2016
    Posts:
    184
    Wow. Incredibly helpful and thank you all. You DoTweeners are a fantastic bunch!

    --- additional question ---

    What is the most performant way to kill ALL tweens on an object?

    I see varying thoughts on this subject and wonder if any of you may know.

    Supposedly transform.DOKill() is much slower than other methods?
     
    Last edited: Jan 12, 2021
  48. watchagames

    watchagames

    Joined:
    Oct 1, 2017
    Posts:
    26
    Hi all,
    Love DoTween, (using Pro).

    I'm tweening a lot of objects so I decided to set capacity at init but so far no result, DOTween still needs to incr capacities at runtime.

    I Made sure to do the Init a the first thing boot scene so should be ok as no Tweens are active.
    upload_2021-1-12_13-44-45.png
    (vals are 60000,30000)

    Still get: (when spawning large qties of obj with tweens on them)
    upload_2021-1-12_13-44-9.png

    Is there something I m missing there ?
    Did not find a way to set those values in the settings windows of DoTween.

    Thanks a lot.
     
  49. FuguFirecracker

    FuguFirecracker

    Joined:
    Sep 20, 2011
    Posts:
    419
    58,000 Tweens ?! You're doing something wrong.
    Are you creating tweens inside an Update loop, or do you really have 58,000 gameObjects moving across the screen at the same time ?
     
  50. FuguFirecracker

    FuguFirecracker

    Joined:
    Sep 20, 2011
    Posts:
    419
    It's been said that "unnecessary performance optimization is the root of all evil" !
    Who said that? Mighta been me ..

    Kidding aside, the general rule of thumb is that you should only concern yourself with such things if you really need it.
    If you're 2 frames shy of 60 at runtime, you might want to look at squeezing every little optimization you can, but other that that, let it be.

    And I know ... I hate it too when 'experts' chime in with answers that don't actually answer the question ...
    I'm usually thinkin' "I asked for an answer not a damned opinion !" ;)

    My actual answer is : I don't know. I've never ever found it necessary to benchmark this.