Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice
  2. Ever participated in one our Game Jams? Want pointers on your project? Our Evangelists will be available on Friday to give feedback. Come share your games with us!
    Dismiss Notice

DOTween (HOTween v2), a Unity tween engine

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

  1. bali33

    bali33

    Joined:
    Aug 14, 2011
    Posts:
    163
    Hello,

    I have a UI item that can be moved, shake, fade etc. Each time one of this operation occurred I store tween operation into a Sequence and at the beginning of each I killed the sequence to be sure that nothing else is modifying my item. I do so using something like :
    Code (CSharp):
    1. _currentSequence?.Kill();
    But doing this I got a lot of warning that the tween is no longer valid. I have the feeling that it is related to tweening recycle because the issue disappear when recycling is disabled. But I'd like to use recycling because I have to tween a lot of objects very fast at some point. So would be great to understand what is happening here.

    Thanks
     
  2. toddhdavis

    toddhdavis

    Joined:
    Oct 18, 2018
    Posts:
    4
    Check your actual code and make sure the casing is correct. I had a similar error and then noticed that I had typed "doMove()" and not "DOMove()". Just a thought.
     
  3. FuguFirecracker

    FuguFirecracker

    Joined:
    Sep 20, 2011
    Posts:
    280
    He has probably already figured it out in the 5 years since that question was asked.
     
  4. cr281164

    cr281164

    Joined:
    Mar 5, 2013
    Posts:
    8
    Hello, I just purchased DOTween Pro and have been able to do most things I need (loving it BTW!!). The only thing I haven't quite worked out is nested sequences. I am trying to tween a series of buttons in a sequence which is being done in a for loop but it doesn't behave how I thought it would.

    Initially I just tried to append to a sequence for each button and then for each button I tied to append that sequence to another sequence, hoping that they would all tween one after another but I found that the first sequence would run automatically for each iteration of the loop (they effectively all ran at the same time). I changed the code to use a new sequence for each button and added those to my nested sequence. This worked better but I am not sure I am doing it correctly because the sequence actually runs even if I don't play it?

    Anyway, it kind of works, I just don't really understand why or whether I am doing it correctly. I also don't really understand what the "Complete() does?"

    My code is as follows:

    public void SpellWord(string word)
    {
    Sequence spellWord = DOTween.Sequence();

    int noLettersButtons = popupLettersButtons.Length;
    Sequence[] letterAnim = new Sequence[20];

    for (int l = 0; l < noLettersButtons; l++)
    {
    if (popupLettersButtons[l].activeInHierarchy)
    {
    letterAnim[l] = DOTween.Sequence();
    GameObject theButton = popupLettersButtons[l];
    Image buttonImage = theButton.GetComponent<Image>();
    TextMeshProUGUI tmpObject = theButton.GetComponentInChildren<TextMeshProUGUI>();
    string buttonLetter = tmpObject.text;

    letterAnim[l].Append(theButton.transform.DOScale(2, 0.75f).SetEase(Ease.OutQuad));
    letterAnim[l].Join(tmpObject.DOFaceColor(new Color32(255, 0, 0, 255), 0.75f));
    letterAnim[l].Join(buttonImage.DOColor(new Color32(34, 125, 183, 255), 0.75f));
    letterAnim[l].InsertCallback(0.25f, ()=>PlayLetterAudio(buttonLetter));
    letterAnim[l].AppendInterval(0.1f);
    letterAnim[l].Append(theButton.transform.DOScale(1, 0.75f).SetEase(Ease.OutQuad));
    letterAnim[l].Join(tmpObject.DOFaceColor(new Color32(255, 255, 0, 255), 0.75f));
    letterAnim[l].Join(buttonImage.DOColor(new Color32(34, 125, 183, 0), 0.75f));
    //letterAnim[l].Complete();
    spellWord.Append(letterAnim[l]);
    }
    }
    spellWord.Play();
    }
     
  5. lemmons

    lemmons

    Joined:
    Jun 20, 2016
    Posts:
    10
    I've searched the thread and read a lot about chaining Tweens using .onComplete() but what if I want to callback a different method? I can't quite figure it out.

    Like here, I'm trying to fade out my pause menu then call the method to unpause my game when it's complete. I'd imagine I could do something like:

    fadeOutSequence.Play().onComplete(UnpauseMethod());


    or like the same thing if I wanted to disable an object once it's been used via a lambda


    outSequence.PrependInterval(exitDelay).Play().onComplete(() =>
    {
    gameObject.SetActive(false);
    });


    But I'm getting the error "Delegate TweenCallback does not accept 1 argument" but according to this post in this thread it looks like it should work. What am I missing?

    I'm pretty new to this whole thing so any direction would be greatly appreciated. Thanks in advance!
     
    Last edited: Apr 15, 2020
  6. FuguFirecracker

    FuguFirecracker

    Joined:
    Sep 20, 2011
    Posts:
    280
    Change you AutoPlay settings in "Preferences". I prefer that "Tweeners" play automatically and sequences only when I tell them to.

    2020-04-15.png
     
  7. FuguFirecracker

    FuguFirecracker

    Joined:
    Sep 20, 2011
    Posts:
    280
    Capitol "O" on that OnComplete.
    ( a common gotcha" )
     
    lemmons likes this.
  8. lemmons

    lemmons

    Joined:
    Jun 20, 2016
    Posts:
    10
    @FuguFirecracker wow thanks for getting back so quickly, and so glad it's an easy fix! Playing around with this I realized you can
    .onComplete
    a tween but you've gotta
    .OnComplete
    a sequence. Just because I'm interested, what's the reason there?
     
  9. indieDoroid

    indieDoroid

    Joined:
    Jan 25, 2016
    Posts:
    271
    I got this error.. I'm not sure what this means? Can anyone help?

    Code (CSharp):
    1. DOTWEEN ► Max Tweens reached: capacity has automatically been increased from 3125/50 to 7812/50. Use DOTween.SetTweensCapacity to set it manually at startup
     
  10. FuguFirecracker

    FuguFirecracker

    Joined:
    Sep 20, 2011
    Posts:
    280
    There's meaning , and then there is meaning.

    The literal meaning is that DoTween has increased the tween pool size for you automatically behind the scenes because you went over the number of tweens initially defined in preferences. Do note, nowhere does this message herald itself as an error. It is not an error. It is a message to you , the developer.

    Now for actual meaning:
    You are generating a crazy amount of tweens ( close to 8,000 ) so my guess is that you are creating tweens in an update loop. Do not do this. Do not create tweens in Update. You can't tween anything between frames. Any tween behaviour that may be manifesting is actually hundreds ( in this case thousands ) of executing methods ....

    That's my guess ... Or maybe you actually do have 8 000 game objects on screen ..
     
  11. indieDoroid

    indieDoroid

    Joined:
    Jan 25, 2016
    Posts:
    271

    Hmm... that sounds like a crazy large amount.

    Thanks for the explanation. I got some code optimizing to do
     
    FuguFirecracker likes this.
  12. YHX2000

    YHX2000

    Joined:
    Aug 2, 2015
    Posts:
    17
    Hi, I have dumb question, why my tween is not working :D
    I'm simply using MoveX from X 500 to X -54 on Start() but the UI Button is moved to X -862.9994 is this unity settings ?
    I'm attaching images and code.
    Thanks in advance for any help !!!

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using DG.Tweening;
    5.  
    6. public class TweenMover : MonoBehaviour
    7. {
    8.  
    9.     public GameObject uiBtn;
    10.     // Start is called before the first frame update
    11.     void Start()
    12.     {
    13.         uiBtn.transform.DOMoveX(-54f, 1.7f, false).SetEase(Ease.OutQuart).SetLoops(1);
    14.     }
    15. }
    Step 1: -> Initial position
    1.png

    Step 2: -> Expected MoveX
    2.png

    Step 3 -> Actual MoveX
    3.png
     
  13. sergioschiavo

    sergioschiavo

    Joined:
    Feb 11, 2014
    Posts:
    23
    Hello,

    I have a question related to DOTweenModulePhysics2D.
    When doing a "Transform" I have the option to do a 'DOLocalMove'.

    Is it possible to do a "RigidBody2D" local move? seems like the only option is to move according to world space.
     
  14. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    1,643
    I am not sure if it has to do with recent version of Unity, but I have started getting error
    "Unknown Assembly DOTween"
    when I start play the game.

    Unknown Assembly DOTween
    UnityEditor.EditorApplication:set_isPlaying(Boolean)
    Unity.Entities.Editor.LiveLinkToolbar:TogglePlaying() (at Library/PackageCache/com.unity.entities@0.7.0-preview.19/Unity.Entities.Editor/LiveLink/LiveLinkToolbar.cs:91)
    Unity.Entities.Editor.LiveLinkToolbar:DrawPlaybar(CommandExecuteContext) (at Library/PackageCache/com.unity.entities@0.7.0-preview.19/Unity.Entities.Editor/LiveLink/LiveLinkToolbar.cs:58)
    UnityEngine.GUIUtility:processEvent(Int32, IntPtr)

    Maybe this is to do with Unity Entity.. not DOTween, but I am posting because well, I want to be sure.

    Unity version 2019.3.10f1
     
    ocnenued likes this.
  15. prometeoproduction

    prometeoproduction

    Joined:
    Apr 19, 2019
    Posts:
    17
    I repeat the question because I haven't found an answer yet:

    Hello, great asset and very useful...

    I have a question and looking for this thread I found no answer, basically every time an event happens in the game I create a sequence in this way:

    Code (CSharp):
    1.  
    2. Sequence sequence = DOTween.Sequence();
    3.  
    4. sequence.Append(transformToScale.
    5. DOScale(vectorToScaleDown, 0.3f).
    6. SetEase(Ease.InOutSine))
    7. .AppendInterval(0.1f)
    8. .Append(transformToScale.
    9. DOScale(vectorToScaleUp, 0.3f).
    10. SetEase(Ease.InOutSine))
    11. .AppendCallback(() => { });
    I was wondering if Sequence sequence = DOTween.Sequence(); generates garbage every time it's called, since it returns a new sequence from what I read.

    I worry because these events happen often and I don't want to generate garbage so often.

    Do they generate garbage?

    If so, is there a way not to generate garbage?

    Thank you.
     
  16. Cris_2013

    Cris_2013

    Joined:
    Nov 25, 2017
    Posts:
    26
    Hi there,

    Currently Unity is freezing when I stop running the game on the editor. I've been working on this project for a few months and never experienced any issue, but recently I've updated Unity and to the Universal Render Pipeline and it started to freeze when I stop run mode.
    My current versions are:
    Unity 2019.3.9f1
    DOTween 1.2.335
    DOTween Pro 1.0.178

    I've been reading online and it seems the issue is cause due to threads not being terminated properly. I've connected Visual Studio and paused the execution when Unity is frozen, and then check the Parallel Stacks window, there is only one thread and most of the items inside are from DOTween.
    I've tried to disable safe mode and play with DOTween init settings, but the game always freezes when I stop run mode, and to my testing it only freezes when a tween is running.

    The platform I am developing is Windows (32 bits) with Oculus Integration.

    I'd really appreciate any comments or help on this matter. Thanks in advance!
     
  17. Cris_2013

    Cris_2013

    Joined:
    Nov 25, 2017
    Posts:
    26
    As far as I know, you can set an initial size of sequences (I believe by default DOTween allows 50 sequences), check the Init function on the documentation. As far as I know you can flag DOTween to pool tweeners and instances so they get reused rather than create new ones:
    http://dotween.demigiant.com/documentation.php?api=SetTweensCapacity
     
    prometeoproduction likes this.
  18. Immu

    Immu

    Joined:
    Jun 18, 2013
    Posts:
    178
    Hello : P
    My Unity Collaborate Cloud build sends me some
    16: [Unity] Error: Could not load signature of DG.Tweening.ShortcutExtensions46:DOColor due to: Could not load file or assembly 'UnityEngine.UI, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. assembly:UnityEngine.UI, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null type:<unknown type> member:(null) signature:<none> 


    Could you help me redirecting my thoughts, do you think It's more on DG.Tweening side, my side or unity team side ? (Maybe wrong import of the UI package..?)
    I'm on 2019.3.10f1
     
  19. iMobCoding

    iMobCoding

    Joined:
    Feb 13, 2017
    Posts:
    53
    Did you properly setup DOTween? Open DOTween panel and try setup again, also try with and without creating ASMDEF
     
  20. Hazneliel

    Hazneliel

    Joined:
    Nov 14, 2013
    Posts:
    198
    Hello

    Has rotateAround been implemented? It's been 5 years in the TODO List.
     
  21. Alejandro-Martinez-Chacin

    Alejandro-Martinez-Chacin

    Joined:
    Oct 15, 2013
    Posts:
    54
    Had a suggestion:
    The sprites have a Height/Width property when used in sliced version. It would be great to have the option to target that using the UIWidthHeight target mode.

    Is that doable?
     
  22. iMobCoding

    iMobCoding

    Joined:
    Feb 13, 2017
    Posts:
    53
    You can always use generic way to access any value, even it's not supported directly by shortcuts
     
  23. Alejandro-Martinez-Chacin

    Alejandro-Martinez-Chacin

    Joined:
    Oct 15, 2013
    Posts:
    54
    My bad didn't clarify, DOTweenAnimation component visually doesn't allow for generic expressions (now that you mention it it would be amazing, would open the possibility to drive material parameters and infinite stuff if we could put a 'getter' and 'setter' there)
    And since it already can target UI rect's WidthHeight (and everything else) it's mostly missing that for sprites too (it can target everything else except that)
    Very useful to be able to do it on the inspector without even having to cook up a small script and hitting play on the viewport (this is such an amazing feature really, loving that)
     
  24. Pan_Tostado20

    Pan_Tostado20

    Joined:
    Apr 9, 2020
    Posts:
    1
    Hi,

    Just bought DOTween. Right now I'm trying to hide/unhide a menu panel using the Movement tween, if I uncheck Autoplay and Autokill I can play it normally to unhide the menu and then backwards to hide it with two assigned buttons, but after playing "one cycle", trying to play it normally doesn't work.

    Is there a hidden flag or something that I must reset? Because apparently if I play it backwards and then manually hit Restart, the button to play it normally works again.

    Something extra that I wanted to ask, for those who have been using DOTween from before and have experience with it, something like this (the menu that hides and unhides) would be better with two separate movement tweens instead of just one?

    And secondly, would you rather do it from script than from the inspector? I avoided creating a script because I thought that it's a very basic animation, just something moving back and forth, so imagined there would be no need for this case, but if you guys think it's way better to control them from script... Just looking for opinions on the matter. Thanks for your time. :)

    Edit: Grammar stuff.
     
  25. Alejandro-Martinez-Chacin

    Alejandro-Martinez-Chacin

    Joined:
    Oct 15, 2013
    Posts:
    54
    If it is of any help, I tend to avoid scripts too for very simple things... then suddenly doing magical very complex animations for UI and generic things becomes a breeze.
    If you have all the buttons:
    - On the event of one bind it to a call to "DOPlayForward" and on the other button to "DOPlayBackwards" on the same DOTweenAnimation.

    Also, utility scripts to make it all worthwhile:
    - I ended up creating a very simple script reusable on many places, called OnEnableDisableEvents, basically it has UnityEvents being called at each step of the MonoBehaviour execution timeline (Awake, Start, OnEnable, OnDisable, etc)...
    - OnEnable one becomes very useful because you can hook on the UnityEvent on that OnEnable to trigger a DORestart of your DOTweenAnimation (trick: if you have many DOTweenAnimation Components in a single GameObject whether it targets itself or others, having the same ID on all of them will make them all playback by only calling DOPlaySomething on the very first one).
    - That way enabling/disabling the object at will, will guarantee that your animation plays back from the very beginning always.
    - You could play then an animation for the backwards that calls gameobject.SetActive(false) on the OnComplete part of any of your DOTweenAnimation component Event callbacks (usually the longest one).
    - Useful for example for pop-up dialogs: getting on a trigger enables a dialog fully animated, with a discard buttons that plays the exit animation and disables).

    This also has the added benefit of disabling the object if not needed freeing up the cost of having that hierarchy sub-set running.

    My .2cents
     
    Pan_Tostado20 likes this.
  26. IvayloDev

    IvayloDev

    Joined:
    Apr 20, 2015
    Posts:
    12
    Hello, I am just starting to use DOTween and I encountered a problem when Animating UI.

    I have attached a function on a button click that calls DOScale with some value and setLoops(2, yolo) to go back to the original scale, but when you press the button repeatedly the scale increments and goes up and up and never comes down. Has any of you encountered this issue and if so is there a solution ? Thanks
     
  27. Lukisio

    Lukisio

    Joined:
    Jul 7, 2015
    Posts:
    3
    Hi!
    I expected there will be some categories or different topics in an official DOTween forum, but let it be ;)

    I'm having a bit of a problem using the DOTweenAnimation move from the DOTween Pro package. I noticed DOPlay will do nothing if the object was already moved by other scripts. Even if it stays still for now. Is this a bug or a feature?
    I would like to make an object flying, but when I call DOPlay, animation should move objects to the center of the screen within a second, from any place it actually is. So I set all the values as on a screenshot. And unfortunately, it doesn't work at all.

    Also, I noticed that Preview Mode won't work if there's a Rigidbody on the object which we want to move, but during gameplay animation works (until we start it in the object's starting position).
    Thanks in advance
     

    Attached Files:

  28. Hazneliel

    Hazneliel

    Joined:
    Nov 14, 2013
    Posts:
    198
    Hello
    How can I Translate? Basically I want to tween movement in Space.Self

    Thank you.
     
  29. Jayme65

    Jayme65

    Joined:
    Dec 11, 2016
    Posts:
    78
    Hi,
    Sometimes I get such a message:
    DOTween's safe mode captured 1 errors. This is usually ok (it's what safe mode is there for) but if your game is encountering issues you should set Log Behaviour to Default in DOTween Utility Panel in order to get detailed warnings when an error is captured (consider that these errors are always on the user side).
    - 1 missing target or field errors

    Where can I then see those 'detailled' error message? In this example, it is question of a '1 missing target or field errors'...where can I get more info about this?
     
  30. Aurigan

    Aurigan

    Joined:
    Jun 30, 2013
    Posts:
    226
    So ... I have three DOTweenAnimation components on a prefab. The first fades it in with no delay, second moves it without delay, third fades it out after a delay. This all works perfectly when using the preview mode, or if I spawn a clone of the prefab.

    But, if I try to restart the tweens using `DORestart()` (I'm using a pooling solution), the tween with a delay doesn't play. It's OnComplete callback still fires at the expected time it just, doesn't fade anything out.

    Code (CSharp):
    1.     public virtual void OnSpawn()
    2.     {
    3.         foreach (var t in GetComponentsInChildren<DOTweenAnimation>())
    4.         {
    5.             t.DORestart();
    6.         }
    7.     }
    Looking at what DORestart() actually does ... it's calling `DOTween.Restart(this.gameObject);` so, me trying to restart 3 DOTweenAnimation components, will restart all the tweens on the gameObject 3 times over. This seems ... wrong but is it also the reason it's not working as expected?

    Edit - tried replacing the broken fade tween with a relative localMove one. Without the DORestart() calls the 2nd localMove will animate movement from wherever it happens to be when the delay expires (expected). With the DORestart() calls, the 2nd localMove will reset position to the start position, before any tweens animate anything, and then animate from there (broken).
     
    Last edited: May 5, 2020
  31. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    1,643
    This could potentially be a bug in DoTween.

    I am using reference to the tween to kill it, but using

    reference.Kill();
    and
    DoTween.Kill(reference);

    works differently. So far, difference is that if I have reference as say tween a position of child object and have another tween for moving parent object and then have them both play at the same time, and then kills the child tween reference, the parent tween also gets killed. ( if I am using reference.Kill() method) the other DoTween.Kill() seems to work correctly.
     
  32. indieDoroid

    indieDoroid

    Joined:
    Jan 25, 2016
    Posts:
    271
    I'm having similar problems... it's not getting killed when i call the method

    Code (CSharp):
    1.   Sequence _dotweenSequence;
    2.  
    3. void Start()
    4. {
    5.     _dotweenSequence = DOTween.Sequence();
    6. }
    7.  
    8. void DoStuff()
    9. {
    10.     _dotweenSequence.Append(gameObject.transform.DOLocalMove((1,1,1), 3);
    11. }
    12.  
    13. void OnPress()
    14. {
    15.     _dotweenSequence.Kill();
    16. }
     
    Last edited: May 8, 2020
    castor76 likes this.
  33. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    1,643
    I am starting to feel that this "may" something to do with recyclable tweens... but I am still trying to understand how to deal with it correctly... Still, something is not right here, or I am not using/handling the tween creation and killing it properly. But it's weird that killing the tween that is affecting the child transform kills the tween affecting the parent transform, even if their reference to the tweens are different. Also happens when I dont use references.. WEIRD!
     
  34. indieDoroid

    indieDoroid

    Joined:
    Jan 25, 2016
    Posts:
    271
    Hmm your requirement seems to be different for mine.. I just want to kill a single tween.

    But anyways I got it to work, with this hack. I don't think it's the proper way though.. Hope it helps someone.

    Code (CSharp):
    1. void DoStuff()
    2. {
    3.     _dotweenSequence = DOTween.Sequence();
    4.     _dotweenSequence.Append(gameObject.transform.DOLocalMove((1,1,1), 1);
    5. }

    EDIT*
    Much thanks from the Dotween author. Here's how to properly set a reference for a Dotween.. for newbs like myself that didn't know.

    Code (CSharp):
    1. Sequence _s;
    2.  
    3.     private void Start()
    4.     {
    5.         _s = DOTween.Sequence();
    6.         _s.Append(gameObject.transform.DOMoveX(2, 1));
    7.     }
    8.  
    9.     private void Update()
    10.     {
    11.         //Some code to accept inputs
    12.         _s.Kill();
    13.     }
    14.  
     
    Last edited: May 11, 2020
  35. ericford

    ericford

    Joined:
    Jul 28, 2017
    Posts:
    2
    Hi I just purchased Do Tween Pro. I am loving the visual editor for the DOTween Animation component. Really easy to make some fast tweens. I did have one question though, is there no simple way for me to implement a FROM and TO within the same component? Like, if I want to scale an object from 0 to 1, can I not have my tween set a starting scale of 0 before beginning the tween to 1? Do I really need to use two different components?
     
  36. FuguFirecracker

    FuguFirecracker

    Joined:
    Sep 20, 2011
    Posts:
    280
    Hazneliel likes this.
  37. Hazneliel

    Hazneliel

    Joined:
    Nov 14, 2013
    Posts:
    198
    I'm trying to blend 2 tweens mutating 1 value. I need this to be able to blend 2 tweens affecting the same blendshape. The use case is that the blendshape is dialed up by user interaction and it can be triggered many times, I dont want to abruptly terminate the tween to start a new one since it looks bad.

    Thanks in advance
     
  38. FuguFirecracker

    FuguFirecracker

    Joined:
    Sep 20, 2011
    Posts:
    280
    Exactly what is it you are trying to do?
    Skeletal animation ? Morph a mesh ? Move stuff across the screen? A fourth thing ?

    I would go about it differently dependent on the requirements.

    The basic idea would be:
    Get Values from TweenA.
    Get Values from TweenB
    Stop both tweens
    Create TweenC from the average data of TweenA & TweenB

    Anything related to realistic || believable movement you would need to account for in how you stop || slowdown the first 2 tweens before setting TweenC in to motion.

    That is: Do you need hesitation? Anticipation? Squash and stretch ? Follow through ? A fifth thing ?
    Those are all thing relevant to the art of animation.

    You can get the tween values from the OnUpdate() method of the tween || tweener.
     
  39. Hazneliel

    Hazneliel

    Joined:
    Nov 14, 2013
    Posts:
    198
    Thanks, I intent to use it for hit expressions, since a hit can occur at any time and multiple times in a row, everytime there is a hit I tween a blendshape. If this tween is cancelled and recreated the expression will abruptly reset and start again. What I want is to not cancel any tween but trigger a new tween on the same blendshape. This 2 tweens will blend each other and the expression will look smooth.

    Maybe there is another way to accomplish what I need but this is what Im trying now.

    Thanks
     
  40. FuguFirecracker

    FuguFirecracker

    Joined:
    Sep 20, 2011
    Posts:
    280
    Post some code, please
     
  41. Hazneliel

    Hazneliel

    Joined:
    Nov 14, 2013
    Posts:
    198
    At first I tried:

    Code (CSharp):
    1.     public void doHitReaction() {
    2.         DOTween.To(()=> mesh.GetBlendShapeWeight(2), x=> mesh.SetBlendShapeWeight(2, x), 100, 2).SetLoops(2, LoopType.Yoyo);
    3.     }
    But this breaks if doHitReaction() is called multiple times before the Tween is finish. Example:
    - doHitReaction() is called and tween starts
    - Just while the tween is at 70, doHitReaction() is called again
    - The new tween will now start from 70 and will animate from 70 to 100 to 70 in 2 seconds

    The problems with this is:
    1- The tween wont reset to 0
    2- The second tween animates in constant time so for short differences the tween will look slow

    In order to fix this I attempt to canceling the tween and setting the blendshape to 0.0
    Code (CSharp):
    1.     public void doHitReaction() {
    2.         this.tween.Kill();
    3.         this.mesh.SetBlendShapeWeight(2, 0.0F);
    4.         this.tween = DOTween.To(()=> 0.0F, x=> mesh.SetBlendShapeWeight(2, x), 100, 2).SetLoops(2, LoopType.Yoyo);
    5.     }
    The problems with this is that the expression gets abruptly reset to 0

    So I need a way to just trigger Tweens from 0 to 100 and back to 0 that are independent of each other and can blend the same blendshape.

    Some Pseudocode:
    Code (CSharp):
    1.     public void doHitReaction() {
    2.         DOTween.To(from: 0.0F, to: 100.0F, 2).SetLoops(2, LoopType.Yoyo).onUpdate(() => { mesh.SetBlendShapeWeight(0, value);});
    3.     }
    In a way that everytime doHitReaction() is invoked, a new tween is started mutating the weight of the blendshape and the final value of it is the average of all tweens currently mutating it.

    With this I accomplish to ensure the blendshape always returns to 0, and by blending I avoid abrupt animations.

    I hope this was clear and thanks a lot for looking into this.
     
    Last edited: May 13, 2020
  42. Hazneliel

    Hazneliel

    Joined:
    Nov 14, 2013
    Posts:
    198
    Forgot to mention that I need to blend random expressions, so even I tried to have 2 tweens like:
    Code (CSharp):
    1.     public void doHitReaction() {
    2.         this.tweenA.Kill();
    3.         this.tweenB.Kill();
    4.         tweenA = DOTween.To(() => mesh.GetBlendShapeWeight(2), x => mesh.SetBlendShapeWeight(2, x), 100, 1).OnComplete(() => {
    5.             tweenB = DOTween.To(() => mesh.GetBlendShapeWeight(2), x => mesh.SetBlendShapeWeight(2, x), 0, 1);
    6.         });
    7.     }
    Which would always start from where the previous tween left and will always return to 0

    But if I add different blendshape indexes then a previous tween migh have mutated a different index, so if that gets cancelled that blendshape will never return to 0.
     
  43. FuguFirecracker

    FuguFirecracker

    Joined:
    Sep 20, 2011
    Posts:
    280
    Nevermind the Loops, use OnComplete(()=> YourMethodHere );
    Use a parameter instead of the hard-coded duration.

    Also, you should investigate the ChangeEndValue() Method
     
  44. Hazneliel

    Hazneliel

    Joined:
    Nov 14, 2013
    Posts:
    198
    Correct, this is what I used in the additional reply. I still have the problem mentioned there even if I do it this way.

    So it is not a way to blend 2 tweens mutating a single value?
     
  45. FuguFirecracker

    FuguFirecracker

    Joined:
    Sep 20, 2011
    Posts:
    280
    Here is a script that changes the endvalue of a generic tween mid tween and then returns object to original position.
    It's not specifically for skinnedMeshBlendShapes, but the theory is sound.
    Code (CSharp):
    1. using DG.Tweening;
    2. using UnityEngine;
    3.  
    4.  
    5. public class BlendShapeBash : MonoBehaviour
    6. {
    7.     private Tweener _tweener;
    8.     private const float REACTION_TIME = 2;
    9.  
    10.     private void Update()
    11.     {
    12.         if (Input.GetKeyDown(KeyCode.Space))
    13.         {
    14.             if (_tweener != null)
    15.             {
    16.                 _tweener.ChangeEndValue(new Vector3(5, 5, 5), _tweener.position - REACTION_TIME, true);
    17.             }
    18.             else
    19.             {
    20.                 MoveIt(new Vector3(2,2,2));
    21.             }
    22.         }
    23.     }
    24.  
    25.     protected void MoveIt(Vector3 terminusOfArrival)
    26.     {
    27.         _tweener = DOTween.To(()=> transform.position , x=> transform.position = x, terminusOfArrival, REACTION_TIME )
    28.             .OnComplete(()=>transform.DOMove(new Vector3(0,0,0), REACTION_TIME ));
    29.     }
    30. }
    You will need a tweener for each blendshape. You should not be trying to use the same tween to control all the blendshapes
     
    Last edited: May 13, 2020
    Hazneliel likes this.
  46. Hazneliel

    Hazneliel

    Joined:
    Nov 14, 2013
    Posts:
    198
    Thanks, that is what I was thinking, I would need to maintain an map of tweens per blendshape so I can individually control them and have them work concurrently allowing tweens on different blendshapes to finish.

    Thanks for the advice
     
    FuguFirecracker likes this.
  47. Ghetaldus

    Ghetaldus

    Joined:
    Jul 15, 2017
    Posts:
    10
    Getting this error since updating to 1.2.335.
    upload_2020-5-14_12-43-14.png

    It comes up when pressing play and then disappears. It does not seem to impact anything, but it is just annoying seeing it every time I hit play.
    Any clue of how to get rid of it?
     
    ocnenued likes this.
  48. FuguFirecracker

    FuguFirecracker

    Joined:
    Sep 20, 2011
    Posts:
    280
    You don't need a 1:1 map per blendshape ... just one for every concurrent tween you wish to affect.

    For instance ... You wouldn't create a tween for every single one of the eight lip-sync animation phonemes (A, B, C, D, E, F, G, & X) ... You would only need one tween because the mouth don't move 8 ways at once ...
    But if you want to blink and snarl and scrunch up your nose, you'd need tweens for those too.
     
  49. FuguFirecracker

    FuguFirecracker

    Joined:
    Sep 20, 2011
    Posts:
    280
    Delete DOTween
    Delete any Resource Folders DOTween may have created.
    Delete any ASDEF files related to DOTween too.
    Re-import DOTween and run setup.

    Did you really need to do all this ? I dunno... Might be overkill, but it will get rid of your error. [ not a guarantee ]
    I seem to recall there were instructions for updating somewhere... Did you follow those?
    Ah who cares ... Scorched Earth policy ... Burn it all down.
     
    Last edited: May 14, 2020
  50. artemio_morales

    artemio_morales

    Joined:
    Nov 29, 2015
    Posts:
    18
    EDIT: Never mind, figured this out. When I reimported DOTween to solve this, I realized I wasn't deleting all of the old files. After removing DOTween entirely and reimporting from scratch, that fixed the issue.

    Hi all,

    I'm on the latest version of DOTween Pro and it looks like the Add/Remove Modules functionality in the utility panel is no longer working. When I mark the checkbox, and click 'Apply', nothing happens and the settings are not saved.

    Is anyone else running into this issue?

     
    Last edited: May 15, 2020
unityunity