Search Unity

DOTween (HOTween v2), a Unity tween engine

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

  1. TheBooBear

    TheBooBear

    Joined:
    Dec 15, 2011
    Posts:
    95
    I have a quick question about DOPunchScale. Is it possible to tell if it is in progress, so I don't call it too often. I put it on my score script and it works fine as long as the score slowly goes up. If I call it too often, it ends up growing slightly each time.

    Code (CSharp):
    1. void Update ()
    2.     {
    3.         if(gameManager.currentScore != oldScore)
    4.         {
    5.             oldScore = gameManager.currentScore;
    6.             scoreText.text = gameManager.currentScore.ToString("00000");
    7.             transform.DOPunchScale(new Vector3(0.1f,0.1f,0.0f),0.5f,1,0);
    8.         }
    9.  
    10.     }
     
    gamedeveloper0008 likes this.
  2. FuguFirecracker

    FuguFirecracker

    Joined:
    Sep 20, 2011
    Posts:
    419
    Yeah. assign a variable to your tween and check myTween.isPlaying();
    Code (CSharp):
    1. var myTween = transform.DOMove(yadda,yadda,yadda)
    2.         if (myTween.IsPlaying())
    3.         {
    4.             Don't bother doing it again
    5.        }
     
  3. TheBooBear

    TheBooBear

    Joined:
    Dec 15, 2011
    Posts:
    95
    Ok. I tried this and the tween plays the first time only.

    Code (CSharp):
    1. void Start ()
    2.     {
    3.         gameManager = GameManager.Instance;
    4.         scoreText = GetComponent<TextMeshProUGUI>();
    5.         scoreTweener = transform.DOPunchScale(new Vector3(0.1f,0.1f,0.0f),0.5f,1,0);
    6.     }
    7.    
    8.     // Update is called once per frame
    9.     void Update ()
    10.     {
    11.         if(gameManager.currentScore != oldScore)
    12.         {
    13.             oldScore = gameManager.currentScore;
    14.             scoreText.text = gameManager.currentScore.ToString("00000");
    15.             if(!scoreTweener.IsPlaying())
    16.             {
    17.                 scoreTweener.Play();
    18.             }
    19.         }
    20.  
    21.     }
     
  4. FuguFirecracker

    FuguFirecracker

    Joined:
    Sep 20, 2011
    Posts:
    419
    Plays every time:
    Code (CSharp):
    1.  
    2. private Tweener _tweener;
    3.  
    4.     void Update()
    5.     {
    6.         if (_tweener == null || !_tweener.IsPlaying())
    7.         {
    8.             _tweener = transform.DOPunchScale(Vector3.one, 2);
    9.         }
    10.     }
    So does this:

    Code (CSharp):
    1. private Tweener _tweener;
    2.  
    3.     private void Start()
    4.     {
    5.         _tweener = transform.DOPunchScale(Vector3.one, 2).SetAutoKill(false);
    6.     }
    7.  
    8.     void Update()
    9.     {
    10.         if (!_tweener.IsPlaying())
    11.         {
    12.             _tweener.Rewind();
    13.             _tweener.Play();
    14.         }
    15.     }
    Take your pick.
    You're welcome.
     
    Last edited: Mar 14, 2018
    xpath likes this.
  5. TheBooBear

    TheBooBear

    Joined:
    Dec 15, 2011
    Posts:
    95

    Ahhh!!! I see... SetAutoKill to false...

    Thank you good sir....
     
    FuguFirecracker likes this.
  6. monish_97

    monish_97

    Joined:
    Sep 15, 2016
    Posts:
    2
    I have just started using DoTween (why didn't I do it earlier???). Im loving this. I have a dumb question though.

    How can I use DoTween to smoothly move or rotate(around a point) objects at a constant speed and in loop?

    Thank you so much for this asset. You Rock.

    Edit: I did this but it's not working.

    RedCircle.transform.DOMove (new Vector3 (0f, 5f, 0f), 5f).SetEase (Ease.Linear);
     
    Last edited: Mar 18, 2018
  7. FuguFirecracker

    FuguFirecracker

    Joined:
    Sep 20, 2011
    Posts:
    419
    There is no 'RotateAround' shortcut. The easiest way to accomplish rotating around another object is to create an EmptyGameObject at the point of rotation and parent the orbital object to that empty. One then rotates the Empty.

    OR
    Roll your own method.
    Code (CSharp):
    1.  
    2.   private void DoOrbit(Transform satelite, Vector3 nexus, float distance,  float time)
    3.     {
    4.  
    5.         var forwardVector =  new Vector3(nexus.x , nexus.y , nexus.z + distance);
    6.         satelite.position = forwardVector;
    7.  
    8.         var backVector = new Vector3(nexus.x , nexus.y , nexus.z - distance);
    9.         var rightVector = new Vector3(nexus.x + distance , nexus.y, nexus.z);
    10.         var leftVector = new Vector3(nexus.x - distance , nexus.y , nexus.z);
    11.  
    12.         satelite.DOPath(new[] {rightVector, backVector, leftVector,    forwardVector}, time).SetEase(Ease.Linear);
    13.  
    14.     }
    #Edit

    Okay... it's not a REAL orbit. It's a [not really] close approximation. Want a better looking orbit? Add more vectors. Or use Pi... everybody loves Pi.

    loopyOrbit.gif

    I'll share the code for the above animation if anyone is interested
     
    Last edited: Mar 19, 2018
    leni8ec, kobyle and gegagome like this.
  8. B0b

    B0b

    Joined:
    Sep 26, 2014
    Posts:
    5
    Hello is there a way to support dotween with chronos in playmaker ?
     
  9. gegagome

    gegagome

    Joined:
    Oct 11, 2012
    Posts:
    392
    Hi there

    I need to know when DOTweenAnimation.isActive is actually false, or when A DOTweenAnimation is running. Does anyone know how to do this please?

    When I run isActive I always get true even after I pause executing DOPause on the animation.

    Any ideas?

    Thanks
     
  10. FuguFirecracker

    FuguFirecracker

    Joined:
    Sep 20, 2011
    Posts:
    419
    A paused tween is still an active tween... It's actively paused ;)
    You might have better luck with IsPlaying
     
  11. gegagome

    gegagome

    Joined:
    Oct 11, 2012
    Posts:
    392
    @FuguFirecracker I can't find a member isPlaying on DOTweenAnimation

    Thanks
     
  12. flashframe

    flashframe

    Joined:
    Feb 10, 2015
    Posts:
    797
    The DOTweenAnimation has a tween. You can check IsPlaying on that.

    Code (CSharp):
    1. DOTweenAnimation animation;
    2. if(animation.tween.IsPlaying) //do something;
     
  13. gegagome

    gegagome

    Joined:
    Oct 11, 2012
    Posts:
    392
  14. ChrisJD

    ChrisJD

    Joined:
    Aug 11, 2013
    Posts:
    3
    I'm trying to create a tween along a path with an ease at each end of the path. What I really want to be able to do is say "Go from here to here along this path with an ease to max speed over x seconds at the start and an ease to 0 speed over x seconds at the end. Remaining at max speed along the rest of the path (the mid-section)".

    I thought I might be able to do that using a single DOPath but I'm not having much luck. What I currently have is shown below. Which is most of the way there with a couple of issues.

    If I use Ease.Linear I get the max speed I expect along the whole path (obviously without any easing at the ends), but if I use Ease.InOutQuad the ease runs all the way to the middle of the path (before easing back to a stop over the second half of the path) and the transform is moving at twice the speed of the linear tween at the mid point of the path (note that i'm using SetSpeedBased). My expected behaviour was that it would tween to the same max speed that linear goes at and then back down again.

    The other half of the problem being that I only want the easing at the ends and the whole mid section at a constant speed.

    Code (CSharp):
    1. Vector3 lastPosition = transform.position;
    2.         Tweener move = transform.DOPath(waypoints, MovementSpeed, PathType.CatmullRom, PathMode.Full3D, 10) // (destination_pos, MovementSpeed).SetSpeedBased(true);
    3.             .SetLookAt(0.01f, Vector3.forward, Vector3.up)
    4.             .SetLoops(0)
    5.             .SetEase(Ease.Linear)          
    6.             .SetSpeedBased(true)
    7.             .OnUpdate(() =>
    8.             {
    9.                 float speed = (lastPosition - transform.position).magnitude / Time.deltaTime;
    10.                 legAnimator.SetFloat("Forward", speed);
    11.                 lastPosition = transform.position;
    12.             });
    13.  
    14.         yield return move.WaitForCompletion();

    As an alternative I tried creating a linear tween with DOMove for each path segment except the first and last, which had an ease on them instead of linear. This avoids the eases happening over the whole path but doesn't resolve the speed problem. The eased segment tweens don't blend nicely to the linear segments. The ease segments transforms are going faster than the linear speed at the transitions points. (Again, all done with speedbased)

    I fell like I'm probably misunderstanding more than one thing about how the library is supposed to work / be used. Any advise?
     
    curbol likes this.
  15. ElChileVengador

    ElChileVengador

    Joined:
    Feb 4, 2013
    Posts:
    27
    Hi everybody,

    I'm having some issues with triggering methods with callbacks, and I'm wondering if anyone has faced similar problems. My code is rather simple:

    Code (CSharp):
    1. public class PanelBase : MonoBehaviour {
    2.  
    3.     /************************************
    4.      * Base for all panels in the game
    5.      * **********************************/
    6.     protected Sequence introAnim, outroAnim;
    7.     protected RectTransform myRectTrans;
    8.  
    9.     public virtual void Awake()
    10.     {
    11.         transform.localScale = new Vector3(0f, 0f, 1f);
    12.         introAnim = DOTween.Sequence();
    13.         outroAnim = DOTween.Sequence();
    14.     }
    15.  
    16.     public virtual void ShowPanel()
    17.     {
    18.         Debug.Log("Panel for "+gameObject.name+" intro starting");
    19.         introAnim.Append(transform.DOScaleX(1.0f, 0.2f)).InsertCallback(0.3f,IntroMidPoint).Append(transform.DOScaleY(1.0f, 0.2f)).OnComplete(IntroFinished);
    20.  
    21.         introAnim.Play();
    22.     }
    23.  
    24.     public virtual void HidePanel()
    25.     {
    26.         outroAnim.Append(transform.DOScaleX(0f, 0.2f)).Append(transform.DOScaleY(0f, 0.2f)).OnComplete(OutroFinished);
    27.         outroAnim.Play();
    28.     }
    29.  
    30.  
    31.     public virtual void IntroMidPoint() { Debug.Log("base for "+gameObject.name+" intro mid point"); }// Debug.Log("base intro mid point"); }
    32.     public virtual void IntroFinished() { Debug.Log("base for " + gameObject.name + " intro finished"); }// Debug.Log("intro finished"); }
    33.     public virtual void OutroFinished() {Debug.Log("base for " + gameObject.name + " outro finished"); gameObject.SetActive(false); }// Debug.Log("outro finished"); }

    The problem is that for some objects the callbacks work and for other it doesn't. The only difference I've been able to find is that the ones that don't play are objects that are instantiated at run time, while those that are working exist on scene before the game starts. Does anyone know why this could happen. Any info would really help a lot.

    Thanks,
    Rafa
     
  16. Eyehawk

    Eyehawk

    Joined:
    Dec 24, 2012
    Posts:
    288
    Hi there,
    Recently, I noticed on our project that the DOTween editor controls were not painting on my iMac.

    When I clicked on a game object that had a DT component on it, the editor controls didn't show up, and the following error appear. Strangely enough, DOTween still works when run from the editor (or exported to the iPad) and the project is fine on my Windows PC.

    I installed DT on to a new project, and the controls painted fine also.

    I have tried to delete the asset out, and reinstall it, but no luck so far. Any hints?

    >>>
    NullReferenceException: Object reference not set to an instance of an object
    DG.DOTweenEditor.Core.EditorUtils.SetEditorTexture (UnityEngine.Texture2D texture, FilterMode filterMode, Int32 maxTextureSize) (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__DOTween/_DOTween.Assembly/DOTweenEditor/Core/EditorUtils.cs:68)
    DG.DOTweenEditor.Core.EditorGUIUtils.get_logo () (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__DOTween/_DOTween.Assembly/DOTweenEditor/Core/EditorGUIUtils.cs:38)
    DG.DOTweenEditor.Core.EditorGUIUtils.InspectorLogo () (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__DOTween/_DOTween.Assembly/DOTweenEditor/Core/EditorGUIUtils.cs:97)
    DG.DOTweenEditor.DOTweenAnimationInspector.OnInspectorGUI () (at Assets/Demigiant/DOTweenPro/Editor/DOTweenAnimationInspector.cs:133)
    UnityEditor.InspectorWindow.DrawEditor (UnityEditor.Editor[] editors, Int32 editorIndex, Boolean rebuildOptimizedGUIBlock, System.Boolean& showImportedObjectBarNext, UnityEngine.Rect& importedObjectBarRect) (at /Users/builduser/buildslave/unity/build/Editor/Mono/Inspector/InspectorWindow.cs:1253)
    UnityEngine.GUIUtility:processEvent(Int32, IntPtr)
     
  17. brunoricardo3d

    brunoricardo3d

    Joined:
    Mar 23, 2018
    Posts:
    3
    Guys, I'm having an issue with a possible ambiguous call between the Unity's Playable.PlayableExtensions.Play() and TweenExtensions.Play(), heres the error message:
    .Stop() gives the same error as well

    Error CS0121 The call is ambiguous between the following methods or properties: 'DG.Tweening.TweenExtensions.Play<T>(T)' and 'UnityEngine.Playables.PlayableExtensions.Play<U>(U)'

    Its happens in 2017.3.1f1 and 2018.2.0b1. Here's my code:

    Code (CSharp):
    1. void Start () {
    2. StartCoroutine(WaitFunction())
    3.  
    4. }
    5.  
    6. IEnumerator WaitFunction()
    7.     {
    8.    
    9.         PlayableDirector director = ModelTarget.GetComponent<PlayableDirector>();
    10.         Playable directorGraph = director.playableGraph.GetRootPlayable(0);
    11.  
    12.         directorGraph.Play();
    13.  
    14.         yield return new WaitForSeconds(8);
    15.  
    16.         directorGraph.SetTime(8);
    17.         directorGraph.Pause();
    18. }
     
  18. MrMatthias

    MrMatthias

    Joined:
    Sep 18, 2012
    Posts:
    191
    The textmeshpro text animation doesn't recognize unicode escape sequences like \U0000f054, but will show it verbatim
     
  19. Eyehawk

    Eyehawk

    Joined:
    Dec 24, 2012
    Posts:
    288
    I figured it out: I had to rebuild the project from scratch from GitHub, and the issue was resolved.
     
  20. duartedd

    duartedd

    Joined:
    Aug 1, 2017
    Posts:
    150
    I need to jump on the Z axis and not on the Y - anyway to change the DoJump to do this?

    for instance below i modified the dojump and swapped the Y and the Z values - i need to basically do that but need help either getting it to compile and properly implemented and extended or another way suggested.


    Code (CSharp):
    1.     public static Sequence DOJumpExtender(this Transform target, Vector3 endValue, float jumpPower, int numJumps, float duration, bool snapping = false)
    2.     {
    3.         if (numJumps < 1)
    4.             numJumps = 1;
    5.         float startPosZ = (float)target.get_position().z;
    6.         float offsetZ = -1f;
    7.         bool offsetZSet = false;
    8.         Sequence s = DOTween.Sequence();
    9.         s.Append((Tween)DOTween.To((DOGetter<Vector3>)(() => target.get_position()), (DOSetter<Vector3>)(x => target.set_position(x)), new Vector3((float)endValue.x, 0.0f, 0.0f), duration).SetOptions(AxisConstraint.X, snapping).SetEase<Tweener>(Ease.Linear).OnUpdate<Tweener>((TweenCallback)(() =>
    10.         {
    11.             if (!offsetZSet)
    12.             {
    13.                 offsetZSet = true;
    14.                 offsetZ = s.isRelative ? (float)(double)endValue.z : (float)endValue.z - startPosZ;
    15.             }
    16.             Vector3 position = target.get_position();
    17.             // ISSUE: explicit reference operation
    18.             // ISSUE: variable of a reference type
    19.             __Null & local = @position.z;
    20.         // ISSUE: cast to a reference type
    21.         // ISSUE: explicit reference operation
    22.         // ISSUE: cast to a reference type
    23.         // ISSUE: explicit reference operation
    24.         ^(float&) local = ^ (float &) local + DOVirtual.EasedValue(0.0f, offsetZ, s.ElapsedDirectionalPercentage(), Ease.OutQuad);
    25.             target.set_position(position);
    26.         }))).Join((Tween)DOTween.To((DOGetter<Vector3>)(() =>
    27.         target.get_position()), (DOSetter<Vector3>)(x => target.set_position(x)), new Vector3(0.0f, (float)endValue.y, 0.0f), duration).SetOptions(AxisConstraint.Y, snapping).SetEase<Tweener>(Ease.Linear)).Join((Tween)DOTween.To((DOGetter<Vector3>)(() => target.get_position()), (DOSetter<Vector3>)(x => target.set_position(x)), new Vector3(0.0f, 0.0f, jumpPower), duration / (float)(numJumps * 2)).SetOptions(AxisConstraint.Z, snapping).SetEase<Tweener>(Ease.OutQuad).SetRelative<Tweener>().SetLoops<Tweener>(numJumps * 2, LoopType.Yoyo)).SetTarget<Sequence>((object)target).SetEase<Sequence>(DOTween.defaultEaseType);
    28.         return s;
    29.     }
     
  21. flashframe

    flashframe

    Joined:
    Feb 10, 2015
    Posts:
    797
    Sorry deleted my last post in error.

    I originally said:

    Someone wanted to do this a while ago and I suggested the easiest way might be to do it DoLocalJump and parenting.

    You'd need 2 parent objects. The first is rotated 90° on the x-axis. The second is 0° on the X-Axis. Your object has been rotated to face the correct direction. Then you tween the 2nd object using DoLocalJump.
     
  22. MythicalCity

    MythicalCity

    Joined:
    Feb 10, 2011
    Posts:
    420
    Anyone know how to do a move along the transform's forward in it's local space? ie, so that if it is rotated by another tween it will move forward in it's new rotation during the move instead of just moving forward in world space? ie: in iTween this is Space.self.
     
  23. flashframe

    flashframe

    Joined:
    Feb 10, 2015
    Posts:
    797
    Code (CSharp):
    1. DOLocalMove(Vector3 to, float duration, bool snapping)
    2. DOLocalMoveX/DOLocalMoveY/DOLocalMoveZ(float to, float duration, bool snapping)
     
  24. ocholicious

    ocholicious

    Joined:
    Mar 9, 2016
    Posts:
    8
    Hey, everyone. Would anyone be able to point me in the right direction or give me an example code of a tween being used with a 2d animation sprite sheet? Basically interested in knowing how to tween frames from an animation sprite sheet and seeing how it'd be handled in DoTween usage.
     
  25. MythicalCity

    MythicalCity

    Joined:
    Feb 10, 2011
    Posts:
    420
    Sorry, that's not what I meant. I want to move by an amount, not to a specific point, while turning. So with iTween I used a RotateAdd and MoveBy together, but wondering if there is a way to do that with Dotween. So while I am rotating, my forward is changing and I should be going in the forward direction of the object during the rotation, so that it moves in an arc. Using the above just moves in whatever the forward is at the start of the move, so the object will always move straight forward, not in it's current direction along the move. Seems like there should be an option to move forward in it's own self space, not just pick one direction and move in that direction for the entire tween.
     
  26. flashframe

    flashframe

    Joined:
    Feb 10, 2015
    Posts:
    797
    Ah I see, sorry. There’s a shortcut called DOBlendableMoveBy, but not sure if that’ll do it ether. Might have to write a customer tweener to do it.

    You could ask @demigiant on twitter. He doesn’t check this forum, but very responsive over there.
     
  27. MythicalCity

    MythicalCity

    Joined:
    Feb 10, 2011
    Posts:
    420
    Yes, I tried the blendable, same issue. Ok, I'll check with him there, thanks!
     
  28. kobyle

    kobyle

    Joined:
    Feb 23, 2015
    Posts:
    92
    Please do, Thanks!
     
  29. Threeyes

    Threeyes

    Joined:
    Jun 19, 2014
    Posts:
    80
    Thanks for the Great Plugin! I have been working on TimeLine lately, so i wonder:

    1.Is there any plan to support TimeLine Tween?
    2.Can we manually control specific tweener's Update? Because I have try the 'DOTween.ManualUpdate' method, but it seens that it will only update all the tweener that is set to UpdateType.Manual.

    Edit: About the Point two, I find a method called ' tweener.Godo(duration)', which works perfect, even in Editor Mode.
    Hope that auther can expost more function inside DoTweenPath such as CreateTween, so that I can make it even work on Editor mode :)
     
    Last edited: May 24, 2018
  30. baldodavi

    baldodavi

    Joined:
    Nov 9, 2017
    Posts:
    5
    I need to tween something not foreseen by library. I'm using something like that
    Code (CSharp):
    1. DOTween.To(() => skillText.GetComponent<Outline>().effectColor = Color.black, x => skillText.GetComponent<Outline>().effectColor = x, Color.white, 0.8f).SetEase(Ease.OutExpo);
    I'm trying to put this statement in a Sequence trying to integrate it with other tweens.
    Code (CSharp):
    1. Sequence seq1 = DOTween.Sequence();
    2.             seq1.Append(DOTween.To(() => skillText.GetComponent<Outline>().effectColor = Color.black, x => skillText.GetComponent<Outline>().effectColor = x, Color.white, 0.8f).SetEase(Ease.OutExpo));
    3. return seq1;
    When I'm returning this sequence Append on other Sequence the Sequence above block all and Play fail without errors? Anyone have experienced something like that or can purpose an alternative solutions?

    Thanks in advance, David.
     
  31. FuguFirecracker

    FuguFirecracker

    Joined:
    Sep 20, 2011
    Posts:
    419
    9 days later... Sorry I was on a mountaintop.

    Code (CSharp):
    1. using DG.Tweening;
    2. using UnityEngine;
    3.  
    4. // attach to MainCamera or something...
    5. public class Orbitor : MonoBehaviour
    6. {
    7.     public Transform Cube; //set in inspector
    8.     public Transform Sphere;
    9.  
    10.     public enum RotateAround{X, Y, Z}
    11.     public RotateAround OrbitalAxis;
    12.  
    13.     protected void Update()
    14.     {
    15.         if (Input.GetKeyDown(KeyCode.Space))
    16.         {
    17.             DoOrbital(Cube, Sphere.position, 1.3f, 12, 3, OrbitalAxis);
    18.         }
    19.     }
    20.  
    21.     /// <summary>
    22.     /// Rotates an object around another object or any point in world space
    23.     /// </summary>
    24.     /// <param name="orbital">The Transfom of the GameObject you wish to put in orbit</param>
    25.     /// <param name="nexus">The position in world space you wish to orbit around</param>
    26.     /// <param name="distance">Orbital distance from nexus</param>
    27.     /// <param name="fidelity">How many waypoints should be created? More points == smoother orbit. 12 is a lovely number</param>
    28.     /// <param name="time">How long is this going to take?</param>
    29.     /// <param name="orbitalAxis">X,Y, or Z the axis to rotate around</param>
    30.     /// <param name="tilt">Self Explanatory, I should think</param>
    31.     private void DoOrbital(Transform orbital, Vector3 nexus, float distance, int fidelity, float time, RotateAround orbitalAxis, float tilt = 0)
    32.     {
    33.         var orbitalVectors = new Vector3[fidelity + 1];
    34.  
    35.         var degreeIndex = (int) orbitalAxis;
    36.         var degrees = Vector3.zero;
    37.         degrees[degreeIndex] = 360f / fidelity;
    38.  
    39.         var initalVector = new Vector3(nexus.x, nexus.y, nexus.z);
    40.  
    41.         // must add the distance value to an axis that is NOT the OrbitalAxis
    42.         var axisIndexShift = new[] {0, 1, 2, 0};
    43.         initalVector[axisIndexShift[degreeIndex + 1]] += distance;
    44.  
    45.         var tiltVector = Vector3.zero;
    46.         tiltVector[degreeIndex] = tilt;
    47.         var planarVectors = new[] {Vector3.forward, Vector3.forward, Vector3.right};
    48.  
    49.         for (var i = 0; i < fidelity; i++)
    50.         {
    51.             orbitalVectors[i] = Quaternion.Euler(degrees * i) * (initalVector - nexus);
    52.             orbitalVectors[i] = Quaternion.AngleAxis(tilt, planarVectors[degreeIndex]) * orbitalVectors[i] + nexus;
    53.         }
    54.    
    55.         orbital.position = orbitalVectors[fidelity] = orbitalVectors[0];
    56.         orbital.DOPath(orbitalVectors, time).SetEase(Ease.Linear).SetLoops(-1);
    57.  
    58.         //ToDo: Kepler orbits
    59.     }
    60. }
     
  32. codemonkeynorth

    codemonkeynorth

    Joined:
    Dec 5, 2017
    Posts:
    13
    great asset.

    any chance the DORotate extension for a RigidBody2D could be made to use the RotateMode to use the shortest angle?

    anyone have a quick fix for this please? I want my start rotation to be +/- 10 degrees from the final rotation, but currently DORotate will not take the shortest angle between them like it can for Transforms etc, as the RotateMode parameter does not exist.

    thanks
    J
     
  33. george_00

    george_00

    Joined:
    Oct 23, 2015
    Posts:
    19
    Hi there,

    I'm trying to get DOTween Pro to work with TextMesh Pro, but I just get the message that 'DOFade (or whatever TMP specific method I try) does not exist in this context'

    I have included ' using DG.Tweening; ' in the script, and I've tried reimporting DOTween Pro and doing the set up again, but no luck.

    The other DT Pro functions I've tried work fine so far, it's just the TM Pro ones that aren't being recognised.

    I'm using Unity 2017.2 with DTP v0.9.690

    TM Pro version is Release 1.0.54

    Anyone else have an issue like this, or can spot something I'm missing?

    Thanks :)
     
    Last edited: May 20, 2018
  34. eobet

    eobet

    Joined:
    May 2, 2014
    Posts:
    176
    I just began looking into this asset and will most likely buy the Pro version, but let's see if I can get a few things cleared up first:

    * Can you adjust tension of the spline points?
    * Can you set per path point speed?
    * Is the asset supported still? It hasn't received an update for a long time, it seems.
     
  35. arkadsgames

    arkadsgames

    Joined:
    Jun 7, 2017
    Posts:
    4
    Hello, I'm trying to do a sequence without interpolation, i have a movement sequence, but it interpolate between each tween, i want one that doesn't. when the previus end it should jump to the next one. What can I do?
     
  36. flashframe

    flashframe

    Joined:
    Feb 10, 2015
    Posts:
    797
    You can use

    .SetEase(Ease.Linear)

    on a sequence if that's what you're looking for?
     
  37. arkadsgames

    arkadsgames

    Joined:
    Jun 7, 2017
    Posts:
    4
    actually no, this only set the animation curve, is the thing between the tweeners that I want to remove, the first movement should end and jump to the next tween start position, instead of doing an interpolation. tween.gif
     
  38. RendCycle

    RendCycle

    Joined:
    Apr 24, 2016
    Posts:
    330
    Is this fully compatible with Unity 2018.1? Can this be used to move any object even NPCs without the use of Navmesh like for flying/swimming?
     
  39. dred

    dred

    Joined:
    Apr 8, 2013
    Posts:
    30
    Hi all,

    I have a trouble: Using dotween like
    _nextView.transform.DOScale(1.25f, 0.3f).SetLoops(3,LoopType.Yoyo).SetAutoKill(true).OnComplete(UnlockInput); when i call this first time - all is perfect, but second time this not work at all. Maybe someone can help me with that? _nextView -is a rect transform.

    Thanks.
     
  40. flashframe

    flashframe

    Joined:
    Feb 10, 2015
    Posts:
    797
    Can you share your code? If you are calling the tween again, but the object is already scaled to 1.25 then it won't do anything, since the object has already reached the target scale. Are you resizing it somewhere else?
     
  41. Jaruz

    Jaruz

    Joined:
    Jul 4, 2018
    Posts:
    8
    Heya,

    DOTween is pretty awesome! I was only using Unity's Animator before but now life is much simpler ^.^

    I had a question about ending tweens early.

    Right now I'm using:
    preview.DoMoveX(50, 0.2f).Fromt(true);

    But as the player toggles through the characters rapidly, it calls this function again before its over and the preview moves further and further to the right. It becomes 50 in the X from the place it was when it was called.

    So i tried adding preview.DoKill(); before it, thinking it would reset the last tween to its original values before starting the new tween but it didnt work.


    Does anyone know how to cancel a tween and have it return to its values pre-tween? Or will I just have to set its X back to 0 and call the DoMove again?
     
  42. FuguFirecracker

    FuguFirecracker

    Joined:
    Sep 20, 2011
    Posts:
    419
    In dealing with an over-zealous clicker :
    You could check IsPlaying, and only process the click event if it returns false;
    Code (CSharp):
    1.  
    2. //Returns TRUE if the tween is playing.
    3. bool isPlaying = myTween.IsPlaying();
    To maintain a sense of responsiveness, that is to say don't outright reject a click when a tween is in progress...
    I check if the tween is playing, if so, I push the click into a Stack<Action>
    ...Upon completion of the tween, I Pop the stack to get the last Action, if there is one, and then clear the Stack. No need to process the whole stack, just the last thing the user did wile the tween was in progress.

    In this manner, the user can click to his or her heart's content and it will never interfere with a tween in progress, but the fact that the user requested another click action will be noted and processed after the tween in progress.

    Something like this:

    Code (CSharp):
    1. private Stack<UnityAction> _tweenActions = new Stack<UnityAction>();
    2.     private Tween _myTween;
    3.  
    4.     private void OnClick()
    5.     {
    6.         if ( _myTween != null && _myTween.IsPlaying())
    7.         {
    8.             _tweenActions.Push(OnClick);
    9.         }
    10.         else
    11.         {
    12.             _myTween = transform.DOMove(Vector3.forward, 2).OnComplete(()=>
    13.             {
    14.                 _tweenActions.Pop()();
    15.                 _tweenActions.Clear();
    16.             });
    17.         }
    18.     }
    Oh... You're gonna need to check that the Stack length is greater than 0 before you Pop...
     
  43. magna_shogun

    magna_shogun

    Joined:
    May 31, 2017
    Posts:
    2
    Hi, I just started using DOTween. The first thing I wanted to do is a fade out / fade in.

    This is the code:
    Code (CSharp):
    1.         Sequence seq;
    2.         Image img;
    3.         bool playedOnce;
    4.  
    5.         void Start()
    6.         {
    7.             seq = DOTween.Sequence();
    8.             img = GetComponent<Image>();
    9.             playedOnce = false;
    10.         }
    11.  
    12.         void Update()
    13.         {
    14.             if (!playedOnce)
    15.             {
    16.                 seq.Append(img.DOFade(0, 3))
    17.                    .Append(img.DOFade(1, 3).SetDelay(3))
    18.                    .OnComplete(() => playedOnce = true);
    19.             }
    20.             else
    21.             {
    22.                 Debug.Log("here");
    23.             }
    24.         }

    So, what I try to do is fade out, wait 3 seconds, fade in, and then I would change the scene (right now just a Debug print).
    But the print occurs before the fade in even starts.
    My understanding was that:
    1. img.DOFade(0, 3) would execute
    2. When it's finished (because I appended it with the Sequence seq), img.DOFade(1, 3) would wait 3 seconds (SetDelay(3)) and would execute
    3. When the sequence is completed playedOnce would be true.
    Do I misunderstand how DOTween works? Maybe the Tweens are considered complete before they actually finish? Or maybe the delay is not taken into account and after 6 second (the two img.DOFade) is considered completed, even though the second DOFade is delayed 3 seconds?

    Thanks in advance.
     
  44. FuguFirecracker

    FuguFirecracker

    Joined:
    Sep 20, 2011
    Posts:
    419
    Consider moving your tween out of 'Update'
    'Start' seems like a good place to wait 3 seconds, instead of checking that every frame for the length of your game...

    EDIT:


    Code (CSharp):
    1. //Set in Inspector
    2.     [SerializeField]
    3.     private Image _image;
    4.     private const float WAITFORIT = 3;
    5.  
    6.     private void Start()
    7.     {
    8.         DoMyFade();
    9.     }
    10.  
    11.     private void DoMyFade()
    12.     {
    13.         DOTween.Sequence().Append(_image.DOFade(0, 3))
    14.             // Much more reliable results with 'Insert'
    15.             // rather than 'Append'
    16.             .Insert(3 + WAITFORIT, _image.DOFade(1, 3)).OnComplete(() =>
    17.             {
    18.                 Debug.Log("Pudding!");
    19.             });
    20.  
    21.     }
     
    Last edited: Jul 6, 2018
  45. magna_shogun

    magna_shogun

    Joined:
    May 31, 2017
    Posts:
    2
    Thanks! It worked perfectly.
     
  46. RendCycle

    RendCycle

    Joined:
    Apr 24, 2016
    Posts:
    330
    HI! I have a newbie question. I just got DoTween Pro marked version: 0.9.690 (Aug 28, 2017) from the Asset Store. After downloading and importation, I clicked Checked Updates button in the Tools->Demigiant->DoTween Utility Panel. I was redirected to a Demigiant.com webpage and was notified that I have an old version (1.1.640) and suggested upgrading by downloading 1.1.710 which I did. What should I do now to upgrade?

    I've tried copying all the files under DOTween folder which I downloaded before and overwrite those contents in the same folder in my Unity Project. Then clicked Setup DOTween button under the Utility Panel. It finishes but I get Console Errors about duplicates which won't allow me to run my game. How do I do this correctly? I'm using Unity 2018.1.6 by the way if that info matters.

     
  47. RendCycle

    RendCycle

    Joined:
    Apr 24, 2016
    Posts:
    330
    Ok, I figured it out. :p Here's what I did:
     

    Attached Files:

    Last edited: Jul 25, 2018
  48. odysoftware

    odysoftware

    Joined:
    Jul 21, 2015
    Posts:
    84
    Hey there, just started using dotween and i am liking it so far - now I wonder if there is a way to avoid it using DontDestroyOnLoad feature of unity. This feature has been depreciated 1 and 1/2 year ago. My game is using additive scene loading, so I want to put the dotween script into my manager scene. but can't since its auto assigning itself as dontdestroyonload. I was looking if there is a way to manually put the dotscreen script in the scene manager - but its not available as a script.

    So how could this be done?

    Thanks,
    Oliver
     
  49. FuguFirecracker

    FuguFirecracker

    Joined:
    Sep 20, 2011
    Posts:
    419
    The source is available
    https://github.com/Demigiant/dotween
     
  50. dheeraj2016

    dheeraj2016

    Joined:
    Mar 8, 2017
    Posts:
    2
    Hi ,
    I am new to Unity and DOTween and just installed it in my small project as per the instruction mentioned on Site.

    but when i tried using it for moving my canvas from a vector to another then i got compile error.
    upload_2018-7-25_13-9-30.png

    Please help ,
    whats is wrong here and how can i correct it ?