Search Unity

DOTween (HOTween v2), a Unity tween engine

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

  1. Ant1m3tas

    Ant1m3tas

    Joined:
    Feb 24, 2015
    Posts:
    4
    When attaching doTweenPath to multiple objects on scene, is it possible to preview all their paths simultaneously somehow?

    Thanks in advance!
     
  2. FuguFirecracker

    FuguFirecracker

    Joined:
    Sep 20, 2011
    Posts:
    419
    Ahoy Ahoy,
    Me again...

    Possible to use DoTween to Change vertex colours?
    I gave it a good ol' go... but wasn't able to puzzle out how to do it.
    Again, maybe I'm overlooking something obvious?

    Here is my Non-DoTween-Centric code what crossfades a purty gradient on a Quad Mesh:
    Code (CSharp):
    1.  // Attach this Script to a Quad
    2.     // Quad needs a Material with a VertexLit Shader
    3.  
    4.     public class BackdropColouring : MonoBehaviour
    5.     {
    6.         private Color32 _topColor;
    7.         private Color32 _bottomColor;
    8.  
    9.         private Mesh _mesh;
    10.  
    11.         private Color[] _meshColors;
    12.  
    13.         private float _lerpTime = 0.01f;
    14.  
    15.         protected void Awake()
    16.         {
    17.             _topColor = Color.black;
    18.             _bottomColor = Color.red;
    19.  
    20.             _mesh = this.GetComponent<MeshFilter>().mesh;
    21.             _meshColors = new Color[_mesh.vertexCount];
    22.  
    23.             ColorIt();
    24.  
    25.         }
    26.  
    27.         protected void Start()
    28.         {
    29.             StartCoroutine(LerpColors());
    30.         }
    31.  
    32.         private IEnumerator LerpColors()
    33.         {
    34.             while (_bottomColor != Color.green) // you've heard of magic numbers? Yeh...well.. this is a magic color
    35.             {
    36.                 _topColor = Color32.Lerp(_topColor, Color.blue, _lerpTime);
    37.                 _bottomColor = Color32.Lerp(_bottomColor, Color.green, _lerpTime);
    38.  
    39.                 yield return new WaitForSeconds(0.1f);
    40.  
    41.                 ColorIt();
    42.             }
    43.  
    44.         }
    45.  
    46.         private void ColorIt()
    47.         {
    48.             _meshColors[0] = _bottomColor;
    49.             _meshColors[1] = _topColor;
    50.             _meshColors[2] = _bottomColor;
    51.             _meshColors[3] = _topColor;
    52.  
    53.             _mesh.colors = _meshColors;
    54.         }
    55.     }
    Any ideas how I can go about doing this with DoTween?
    The only reason I ask is because I want to use DoTween for EVERYTHING, Dammit !!! ;)



    EDIT ################################################

    Nevermind...
    It's lambdas
    Is there anything they cannot do!?
    Well, lambdas and the 'generic' tween.

    I had forgotten about the OnUpdate method until I made the response below regarding OnComplete callbacks

    Here's the Code if anyone is interested:

    Code (CSharp):
    1. // Scrap the Start() method
    2. // Scrap the CoRoutine
    3. // Change ColorIt() method to
    4.  
    5.         private void ColorIt()
    6.         {
    7.             DOTween.To(() => _topColor, x => _topColor = x, Color.blue, 3f);
    8.             var bottomColorTween = DOTween.To(() => _bottomColor, x => _bottomColor = x, Color.green, 3f);
    9.    
    10.             //only need the one pointer as we only need to follow one update to get our result
    11.  
    12.             bottomColorTween.OnUpdate(() =>
    13.             {
    14.                 _meshColors[0] = _bottomColor;
    15.                 _meshColors[1] = _topColor;
    16.                 _meshColors[2] = _bottomColor;
    17.                 _meshColors[3] = _topColor;
    18.  
    19.                 _mesh.colors = _meshColors;
    20.             });
    21.  
    22.          }
     
    Last edited: Apr 12, 2016
    dyupa and Demigiant like this.
  3. FuguFirecracker

    FuguFirecracker

    Joined:
    Sep 20, 2011
    Posts:
    419
    One may do as many callback as one likes upon completion.
    Simply use the lambda ()=>{} syntax
    instead of .OnComplete(YourFabulousMethodHere);
    use the lambda ()=> in lieu of YourFabulousMethod.
    Use { } to enclose all the callbacks you desire.

    Code (CSharp):
    1. this.transform.DOMove(new Vector3(5, 5, 5), 0.5f).OnComplete(() =>
    2.             {
    3.                 transform.DOScale(Vector3.one, 0.6f);
    4.                 CallAnotherMethodHere();
    5.                 LoAnotherMethodCallHere();
    6.             }
    7.             );
     
    Demigiant likes this.
  4. kenlem

    kenlem

    Joined:
    Oct 16, 2008
    Posts:
    1,630
    Is there a call in DotTween to rotate an object around some other point besides its center?
     
  5. TheValar

    TheValar

    Joined:
    Nov 12, 2012
    Posts:
    760
    This works for some cases but in my case I need to be able to tack on additional callback functions at a later time, not just in a single call
     
  6. FuguFirecracker

    FuguFirecracker

    Joined:
    Sep 20, 2011
    Posts:
    419
    Code (CSharp):
    1.  transform.DOMoveX(4f, 3f).OnComplete(() =>
    2.             {
    3.                 DOTween.Sequence().AppendInterval(3f)
    4.                .AppendCallback(DoWhatEverYouWantHere());
    5.             });
     
    Demigiant likes this.
  7. TheValar

    TheValar

    Joined:
    Nov 12, 2012
    Posts:
    760
    I ended up just going to the source code and making my own .dll that with AddOnComplete and RemoveOnComplete functions. I appreciate the suggestions though :D
     
  8. timmehhhhhhh

    timmehhhhhhh

    Joined:
    Sep 10, 2013
    Posts:
    157
    love the asset, bought pro :)

    however, it's automatically creating a [DOTween] gameobject with attached DOTweenComponent wherever it pleases. is there any way to customize this behavior? i like to set things up a and keep them nested certain ways ;)
     
  9. Devil_Inside

    Devil_Inside

    Joined:
    Nov 19, 2012
    Posts:
    1,119
    Hi Daniele!
    I have 2 questions regarding DOTweenPath component:
    1. When I play a DOTweenPath while my object looks in an arbitrary direction, it instantly snaps towards the next point on the path. Is there a way to make it's rotation tween from it's initial orientation to the one following the path?
    2. Is there a way to chain several DOTweenPaths? Or maybe tween to a certain waypoint rather than the endpoint? I've heard about the trick with pausing the tween when at certain waypoint, but I also need the proper easing to work. What would be the best way to do this?
     
  10. TheValar

    TheValar

    Joined:
    Nov 12, 2012
    Posts:
    760
    Just found a bug (sorta) that took me a while to figure out so posting here in case anyone else hits the same issue.
    When using single axis move shortcuts such as DoLocalMoveY, if you want to change the start or end value you need to pass in a Vector3 instead of a float.

    Code (CSharp):
    1. transform.DoLocalMoveY(10, 50).ChangeStartValue(0);
    will not work
    Code (CSharp):
    1. transform.DoLocalMoveY(10, 50).ChangeStartValue(Vector3.zero);
    will work properly
     
  11. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    That's actually by design choice. DOMoveX/Y/Z and the other single-axis shortcuts are actually "shortctuts of shortcuts", and they still use the full Vectory2/3/4 plugin, but simply ignore the other axes. My bad for not explaining it better in the docs, I just added a note there now.

    @Devil_Inside Ahoy!
    1. I'm afraid not, since that would be a tween of a tween, and could create a lot of chaos. Maybe you could first fire a runtime tween to look at the next waypoint, and only after that start the DOTweenPath?
    2. This is something that would require more tricks. You could just use DOTweenPath to create the curves, and then grab the waypoints (myDOTweenPath.wps) and use only the ones you want to create a scripted DOPath.
    @tbriley Thanks for getting the Pro! DOTween really needs a gameObject to live in the scene, because that way it avoids having to add Components to tweened objects. And it needs to be in the root because it is set to DontDestroyOnLoad. If you want though, you can rename it to whatever you like ;)

    @kenlem Sorry no. But you can use a parent-child trick. You center the parent on the target you want to rotate around and tween said parent, so that the child will appear as it's rotating around the target.

    @FuguFirecracker Sorry for the delay, glad you solved it in the meantime (lambdas are awesome indeed), and thanks a lot for the support!!!! :)
     
    TheValar likes this.
  12. timmehhhhhhh

    timmehhhhhhh

    Joined:
    Sep 10, 2013
    Posts:
    157
    @Izitmee I get it :) But I'm wondering how do I customize the behavior? Re-name or re-parent it how? I already have a Kernel object for all things DontDestroyOnLoad to live. Putting this directly on my Kernel object doesn't seem to work - it gets removed on scene load. Is there any access to source for something simple like this?
     
  13. Devil_Inside

    Devil_Inside

    Joined:
    Nov 19, 2012
    Posts:
    1,119
    Ok, thanks! I'll try that!

    Edit:
    @Izitmee I've tried looking at the next waypoint, but it's not the proper orientation at the start of the curve. Is there a way to sample the curve at the "lookAhead" position so I could get the exact orientation?
     
    Last edited: Apr 16, 2016
  14. ortin

    ortin

    Joined:
    Jan 13, 2013
    Posts:
    221
    +1
     
  15. gegagome

    gegagome

    Joined:
    Oct 11, 2012
    Posts:
    392
    Hello there

    Can I tween a VerticalLayoutGroup's rect property offsetMin and offsetMax?

    I'm working with a ScrollRect that contains a VerticalLayoutGroup.

    This VerticalLayoutGroup contains all my alphabet letters and I am currently moving them vertically like this:

    I've looked around in the docs and can't seem to find an equivalent.

    Thanks
     
  16. MaZy

    MaZy

    Joined:
    Jun 29, 2012
    Posts:
    105
    I need a help. I am using dotween. I am using the DoShakeRotation for the camera shake. The camera is slowling following a target.

    My problems is if shakeRotation is running (I think) so my camera following script cannot rotate anymore.
    So it looks like at the end like a "freeze" and then resets to real rotation.

    Is this possible to fix it? Cannot both work together? I started to write my own shake.. buts its not same shake :D


    I made a gif. If you see the tank moving after few seconds you can notice it.. after the shake the cam "resets"
     
  17. FuguFirecracker

    FuguFirecracker

    Joined:
    Sep 20, 2011
    Posts:
    419
    @gegagome
    I've learned that one can tween ANYTHING with DoTween if you use lambdas and the generic tweener.
    Code (CSharp):
    1. DOTween.To(() => iWantToTweenThisValue, x => iWantToTweenThisValue = x, myEndValue , 3f);
    BUT
    DoTween does have sortcuts for anchors.
    I know your not asking about anchors specifically, but it may be of some use to you.
    I was never able to get them to behave propererly, possibly due to my own misunderstanding of the anchors and offsets, so if you do get it working with predictable results, please do come back and let us know.

    EDIT#
    Here ya go

    Code (CSharp):
    1.        static   GameObject go = new GameObject(); //
    2.         private RectTransform _rectTransform = go.AddComponent<RectTransform>();
    3.         private VerticalLayoutGroup goVLG = go.AddComponent<VerticalLayoutGroup>();
    4.         private float _scrollTime = 1.2f;
    5.  
    6.         protected void Update()
    7.         {
    8.             if(Input.GetKeyUp(KeyCode.A)){
    9.  
    10.                 DOTween.To(() => _rectTransform.offsetMin, x => _rectTransform.offsetMin = x, new Vector2(0,-3203), _scrollTime);
    11.                 DOTween.To(() => _rectTransform.offsetMax, x => _rectTransform.offsetMin = x, Vector2.zero, _scrollTime);
    12.  
    13.             }
    14.  
    15.  
    16.         }
     
    Last edited: Apr 17, 2016
    Demigiant likes this.
  18. gegagome

    gegagome

    Joined:
    Oct 11, 2012
    Posts:
    392
    Thanks a bunch for the sample code. It worked fine.

    Is there a way to use an ease curve using lambdas?


     
  19. FuguFirecracker

    FuguFirecracker

    Joined:
    Sep 20, 2011
    Posts:
    419
    Yup
    Code (CSharp):
    1. DOTween.To(() => iWantToTweenThisValue, x => iWantToTweenThisValue = x, myEndValue , 3f)
    2. .SetEase(Ease.InBounce); // on 2 lines for readability
     
    Demigiant likes this.
  20. gegagome

    gegagome

    Joined:
    Oct 11, 2012
    Posts:
    392
    Great thanks a lot!

     
  21. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    @FuguFirecracker Thanks again for the support! :)

    @MaZy Ah, DOTween's shake took a lot of work to make it random but with a some logic so that it can look cool :D That said, once a tween is controlling a property, it doesn't allow it to be controlled otherwise. But! You could use a trick. Place your camera inside a parent. Control the parent for rotation/navigation/etc, and shake the child camera. That will allow both to work in conjunction.

    @ortin & @PixelEnvision Sorry guys didn't see these. Just replace the DOTween (only that one, not the Pro too) folder with the new one and run the setup again. I'm working on a new Pro update but it might take some time because I'm trying to do some weird S*** (which is currently not working so I'll probably scrap it, but you never know) :p

    @tbriley Sure! Source is here (DOTweenComponent is the one that is created). I'll check it out too, but let me know if you find a smart solution in the meantime :)
     
  22. TheCelt

    TheCelt

    Joined:
    Feb 27, 2013
    Posts:
    742
    Hello

    I am looking for some advice as i am a bit confused.

    I created a tween like this:


    Code (CSharp):
    1. TweenManager.Kill(tweenID);
    2.  
    3. DOTween.To(()=> transform.position, x=> transform.position = x, target, 3.0f)
    4. .SetEase(Ease.InOutQuad)
    5. .SetId(tweenID);
    But i want to add another tween but not having it run until this one is complete. But it isn't always the case that another tween is needed it really depends on the situation in the game world.

    So is there a way to create a tween then wait for the completion of a different tween by its tweenID? Or perhaps "add" to the already on going tween if there is one on going so that it will then play the next one soon after.

    Also is there a way to setup a tween and not have it run until you call it to run - for example via a function call to start it. Like how do you prevent the auto play of a particular tween? I like to have auto play globally on in the preferences but i just need one or two which are not auto.
     
  23. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    Hi @SirChick

    You can chain a pause to your tween, and it won't start until you call Play.
    Code (csharp):
    1. // Somewhere in your code
    2. Tween myTween = DOTween.To(()=> transform.position, x=> transform.position= x, target, 3.0f).Pause();
    3. // Somewhere else
    4. myTween.Play();
    Or if you don't want to store a reference, you can chain the Pause and then call DOTween.Play(tweenId).

    To call a method at the completion of a tween, you can use OnComplete. It accepts a method or a lambda (anonymous method):
    Code (csharp):
    1. // Like this:
    2. myTween.OnComplete(MyOtherMethod);
    3. // Or like this, for example:
    4. myTween.OnComplete(()=> DOTween.Play(tweenId));
    Also, if you want to just have more tweens connected to each other, you can insert them in a Sequence (note that tweens don't need to be in a sequence inside a Sequence—I know, bad naming there—but they can overlap, as long as they don't tween the same property).
     
  24. TheCelt

    TheCelt

    Joined:
    Feb 27, 2013
    Posts:
    742
    So is a sequence multiple tweens at same time or tweens one after the other ?

    And can a sequence allow me to append a variable of a tween like:

    Code (csharp):
    1.  
    2. //Tween myTween
    3. mysequence.Append(myTween);
    4.  
    Whilst the tween is actually playing?

    Also does a tween's kill command remove the tween from the sequence ? Or do i have to do it manually once it completes?

    Also it seems i can't add to the sequence when its running, so if i queue up tweens I have to pause the sequence first meaning it'll look weird in game won't it ?
     
    Last edited: Apr 20, 2016
  25. Sonoshee

    Sonoshee

    Joined:
    Jul 8, 2014
    Posts:
    77
    Hi there! I was wondering if I could use DOTween to make an object follow a given target. I already have another implementation working nicely, but doesn't ease in/out nicely like DOTween.
    I tried starting the tween in Start() and update its end value in Update(). But the game object seems to be stuck. Any ideas why updating the endValue doesn't work? I tried updating the startValue with the current position as well, still doesn't work.
    Sorry for disturbing.
     
  26. JakeTBear

    JakeTBear

    Joined:
    Feb 15, 2014
    Posts:
    123
    @Sonoshee Tweens automatically get recycled unless you tell them not to, what you trying to do is very simple and it should work fine by changing the endvalue, dont forget to SetAutoKill to false.

    Code (CSharp):
    1. transform.DOMove(Vector3.zero, 1.0f).SetAutoKill(false);
     
  27. Sonoshee

    Sonoshee

    Joined:
    Jul 8, 2014
    Posts:
    77
    I can't believe I made the mistake of setting the duration to a zero value. Happens right? lol
    Thanks for your help @JakeTBear
     
    JakeTBear likes this.
  28. pixpusher2

    pixpusher2

    Joined:
    Oct 30, 2013
    Posts:
    121
    Hi there,

    Just noticed that Material.DOBlendableColor() doesn't work with any property other than the one named "_Color".
    Doing the below gives me error:

    Code (CSharp):
    1. material.DOBlendableColor(Color.blue, "_CustomProperty", 1f);
    Material.DoColor() works fine with the same custom property name however.
    Any ideas? Thanks!
     
  29. sevensails

    sevensails

    Joined:
    Aug 22, 2013
    Posts:
    483
    What is the correct way of Killing an active Tween?

    This seems do does not works for me :
    Code (csharp):
    1. Arrow = GetComponent<RectTransform>().DOAnchorPos(Offset, 1f).SetLoops(-1, LoopType.Yoyo).SetRelative().SetEase(Ease.InOutSine).SetDelay(0.1f);
    2. DOTween.Kill(Arrow);
    Nor this:

    Code (csharp):
    1. GetComponent<RectTransform>().DOAnchorPos(Offset, 1f).SetLoops(-1, LoopType.Yoyo).SetRelative().SetEase(Ease.InOutSine).SetDelay(0.1f);
    2. DOTween.Kill(GetComponent<RectTransform>());
    But this seems to work :
    Code (csharp):
    1. var RectTransform=GetComponent<RectTransform>();
    2. RectTransform.DOAnchorPos(Offset, 1f).SetLoops(-1, LoopType.Yoyo).SetRelative().SetEase(Ease.InOutSine).SetDelay(0.1f);
    3. DOTween.Kill(RectTransform);
    The first two examples are really wrong?
     
  30. JakeTBear

    JakeTBear

    Joined:
    Feb 15, 2014
    Posts:
    123
    @Wagenheimer It might be a bit confusing, but it is also not the optimal way of killing a tween, if you have a direct access to the tween I would recommend killing the tween directly, and not using the DOTween static method to do so.

    Code (CSharp):
    1. Arrow = GetComponent<RectTransform>().DOAnchorPos(Offset, 1f).SetLoops(-1, LoopType.Yoyo).SetRelative().SetEase(Ease.InOutSine).SetDelay(0.1f);
    2. Arrow.Kill();
    The DOTween.Kill method is very handy when you want to kill tweens from a gameobject without really knowing if it has tweens or not. Hope this helps!
     
  31. Miguel-Ferreira

    Miguel-Ferreira

    Joined:
    May 8, 2015
    Posts:
    90
    Hi guys,

    I’m having trouble doing something that ought to very simple. I have a simple infinite loop (
    Code (CSharp):
    1. .SetLoops (-1,LoopType.Yoyo);
    ) that changes the color of a sprite. How can I “smoothly” stop the loop, which effectively means don’t loop anymore after you reach the initial state again?

    The default Kill() behaviour just instantaneously stops the animation no matter where it is, even with the complete parameter set to true. Also, SetLoops() doesn't work after the animation has started. Am I missing something?
     
    Last edited: Apr 30, 2016
  32. Mr_Cad

    Mr_Cad

    Joined:
    Dec 7, 2013
    Posts:
    27
    Hi, may I know how does overshoot parameter works in SetEase() ?

    I try to put some numbers in it but I don't see the overshoot effect
    Currently running on Windows 7, DOTween v1.1.260
     
  33. flashframe

    flashframe

    Joined:
    Feb 10, 2015
    Posts:
    797
    I believe Overshoot will only work with Back eases. There's a good tool here where you can test and preview different eases.

    http://greensock.com/ease-visualizer
     
  34. Mr_Cad

    Mr_Cad

    Joined:
    Dec 7, 2013
    Posts:
    27
    You're right, thanks! It's working now after I use Back eases
     
  35. sevensails

    sevensails

    Joined:
    Aug 22, 2013
    Posts:
    483
    One question!

    The Tween should continue playing even that the parent gameobject is disabled?

    I have a GameObject where I do a DOFade and DOScale on a child of it! But the Tweens keep running even after the Parent GameObject is Disabled (I check in on DOTweens ActiveTweens Inspector).

    After this, if I change the scene, this tween is deleted, but it remains as a NULL activeTween. After some Levels, DOTween completely broke.

    I fixed this Killing the Tween before the Parent GameObject Disables. But I think this should not be necessary, am I correct?
     
  36. FuguFirecracker

    FuguFirecracker

    Joined:
    Sep 20, 2011
    Posts:
    419
    After you reach the initial state again? So you DON'T want an infinite loop? Don't make it an infinite loop.
    If I'm reading correctly, you want your sprite to change from "color a" to "color b" and then back to "color a" and be done with it?

    Code (CSharp):
    1. .SetLoops(2, LoopType.Yoyo);
     
  37. Eroy2

    Eroy2

    Joined:
    Sep 27, 2015
    Posts:
    6
    Hi !

    I have some trouble with a sequence that does not work properly.
    DOScale does not seem to be happy that I'm also tweening the transform's position using DOMove at the same time and fights with it. It struggles to scale up the object and pops it instantly at the end of the position tween.

    If I Instantiate a lot of objects, their sequences get broken an do strange stuff (seems like it tries to shortcut tweens in the sequence so that they end faster). Any idea how I can solve all this ??

    Here is an example code that makes this behaviour happen (on a UI Image) (This is called on Start())

    Code (CSharp):
    1.  
    2. void Sequence() {
    3.     // Stop all current tweens
    4.     transform.DOKill();
    5.  
    6.     var sequence = DOTween.Sequence();
    7.     sequence.Append(transform.DOScale(2f, 0.5f)
    8.        .Join(transform.DOMove(target, 0.5f);
    9.  
    10.     sequence.Play();
    11. }
     
    Last edited: May 8, 2016
  38. Eroy2

    Eroy2

    Joined:
    Sep 27, 2015
    Posts:
    6
    I resolved the fact that Sequence try to finish faster, it was just that an other sequence was getting in the way.

    I still have the problem of the DOScale not behaving correctly while played along a DOMove :/
     
  39. Miguel-Ferreira

    Miguel-Ferreira

    Joined:
    May 8, 2015
    Posts:
    90
    What I meant was : "How can I smoothly (return to initial state) stop a infinite loop animation after starting it"

    I ended up using this

    Code (CSharp):
    1. public void StopLoopingYoYoAnimation(Tween animation) {
    2.         animation.OnStepComplete (() => {if(animation.CompletedLoops().IsEven()){animation.Kill ();}});
    3.     }
     
  40. FuguFirecracker

    FuguFirecracker

    Joined:
    Sep 20, 2011
    Posts:
    419
    define a member variable for the tween.
    define a member variable for your original color.
    kill the tween where ever you like and send it the original color.
    Code (CSharp):
    1. using UnityEngine;
    2. using DG.Tweening;
    3.  
    4. // Attach to Sprite
    5. public class ColorTween : MonoBehaviour
    6. {
    7.  
    8.     private readonly Color32 _originalColor = new Color32(243, 97, 19, 255);
    9.     private readonly Color32 _newColor = new Color32(141, 151, 241, 255);
    10.     private Tweener _yoyoTween;
    11.     private SpriteRenderer _spriteRenderer;
    12.  
    13.     protected void Start()
    14.     {
    15.         _spriteRenderer = GetComponent<SpriteRenderer>();
    16.         _yoyoTween = _spriteRenderer.DOColor(_newColor, 1.2f)
    17.         .SetLoops(-1, LoopType.Yoyo);
    18.     }
    19.  
    20.     protected void Update()
    21.     {
    22.         if (Input.GetKeyDown(KeyCode.Space))
    23.         {
    24.             _yoyoTween.Kill();
    25.             _yoyoTween = _spriteRenderer.DOColor(_originalColor, 1.2f);
    26.         }
    27.     }
    28.  
    29. }
    30.  
     
    Last edited: May 8, 2016
  41. atpkewl

    atpkewl

    Joined:
    Jun 30, 2015
    Posts:
    17
    Hi @Izitmee When I set Ease for anything other than Ease.OutQuad for camera dolookat, it doesnt work properly. MainCamera.transform.DOLookAt(Car.transform.position,1.0f,0,Vector3.up).SetEase(Ease.InOutSine).

    The camera moved very slowly...

    would you please help to look into this ?

    thank you
     
  42. gegagome

    gegagome

    Joined:
    Oct 11, 2012
    Posts:
    392
    Hello there

    I'm tweening a RectTransform to the horizontal center of the screen using:
    Code (CSharp):
    1.  _aRectTransform.DOAnchorPosX(0f,HORIZONTAL_CENTERING_TIME,false).SetEase(Ease.InOutCubic);
    But _aRectTransform won't move while being tweened. How could I trigger the above expression and be able to drag out in the middle of the tween?
    Complete work in progress code: Thanks
    Code (CSharp):
    1. using UnityEngine;
    2. using UnityEngine.EventSystems;
    3. using System.Collections;
    4. using DG.Tweening;
    5.  
    6. public class BigLettersController : MonoBehaviour, IBeginDragHandler, IDragHandler, IEndDragHandler {
    7.  
    8.     RectTransform _aRectTransform;
    9.     bool _isNotInit = true;
    10.     Vector3 _pos;
    11.     const float LIMIT_X = 300f;
    12.     const float HORIZONTAL_CENTERING_TIME = 0.3f;
    13.     public Letter _lastLetter, _currentLetter, _nextLetter;
    14.  
    15.     void Awake () {
    16.         _aRectTransform = GetComponent<RectTransform>();
    17.     }
    18.  
    19.     void Update () {
    20.     }
    21.  
    22.     public void OnBeginDrag (PointerEventData eventData) {
    23.         Debug.Log("Began drag");
    24.     }
    25.  
    26.     public void OnDrag (PointerEventData eventData) {
    27.         if (_isNotInit) {
    28.             _pos = transform.position;
    29.             Debug.Log("initialized at: " + _pos);
    30.             _isNotInit = false;
    31.         }
    32.  
    33.         _pos += (Vector3)eventData.delta;
    34.         transform.position = new Vector3(_pos.x, transform.position.y);
    35. //        transform.position += (Vector3)eventData.delta;
    36. //        Debug.Log(transform.position);
    37.         Debug.Log(_aRectTransform.anchoredPosition);
    38.     }
    39.  
    40.     public void OnEndDrag (PointerEventData eventData) {
    41.         Debug.Log("Released input");
    42.  
    43.         if (Mathf.Abs(_aRectTransform.anchoredPosition.x) < LIMIT_X) {
    44.             _aRectTransform.DOAnchorPosX(0f, HORIZONTAL_CENTERING_TIME, false).SetEase(Ease.InOutCubic);
    45.         }
    46.  
    47.         _isNotInit = true;
    48.     }
    49. }
     
  43. FuguFirecracker

    FuguFirecracker

    Joined:
    Sep 20, 2011
    Posts:
    419
    pure speculation on my part...
    create a member variable for your tween ( you can do so much with your tweens if you'd just name the damned things ! ;)

    OnDrag kill the tween.
    OnEndDrag restart the tween using the same variable, but send it the new rect.
     
  44. rxmarccall

    rxmarccall

    Joined:
    Oct 13, 2011
    Posts:
    353
    Hoping someone could help me out...
    • If I have a path with 3 waypoints (including the origin point), is it possible to have an object start to follow the path at the 2nd waypoint and continue from there rather than starting from the origin point? ( My game camera follows a path so I want it to start in the middle of my path so the player can go left or right from the center )
    • How can I have my camera position snap to a waypoint on the path to begin with?
     
  45. gegagome

    gegagome

    Joined:
    Oct 11, 2012
    Posts:
    392
    I need to try that thanks!

    I have another question below if you don't mind :)
     
  46. ortin

    ortin

    Joined:
    Jan 13, 2013
    Posts:
    221
    @Izitmee
    I was wondering why, when safe mode is enabled and some exception is raised during a tween execution (DOVirtual, OnUpdate etc), nothing is written to the log? Coz safe mode is super cool to deal with all those tweens on destroyed objects, but it eats all exceptions without any logging so it just cannot be used, unless you want to spend a few hours trying to understand why your code isn't working as expected :)
     
  47. German-Krasnikov

    German-Krasnikov

    Joined:
    Mar 30, 2015
    Posts:
    4
    Hi!
    11.png

    I have a distance = 3m and time 3s for which car finish path. The animation is liner, so speed on first line 1,5 m/sec, second 0.5 m/sec, third 1 m/sec. How can car accelerate from 0->1.5m/sec in 1, 2m/sec->0.5m/sec on second and 1m/sec in 3? That was not junping speed.

    Code (CSharp):
    1. public void Start()
    2. {  
    3.     var positions = new[] { new Vector3(1.5f, 0, 0), new Vector3(2f, 0, 0), new Vector3(3f, 0, 0) };
    4.     var durations = new[] { 1f, 1f, 1f };
    5.     DOTween.ToArray(GetPosition, SetPosition, positions, durations)
    6.         .SetEase(Ease.Linear)
    7.         .OnUpdate(OnUpdate);
    8. }
    9.  
    10. protected Vector3 Position = new Vector3();
    11. private Vector3 GetPosition()
    12. {
    13.     return Position;
    14. }
    15.  
    16. private void SetPosition(Vector3 value)
    17. {
    18.     Position = value;
    19. }
    20.  
    21. private void OnUpdate()
    22. {
    23.     Mover.distance = Position.x;
    24. }    
    Sorry for my English.
     
  48. Vincenzo_MAG

    Vincenzo_MAG

    Joined:
    Feb 16, 2015
    Posts:
    1
    Hello, I was wondering, with HOTWeen I was able to perform two transformations at the same time during a sequence, something like:

    seq.Append(HOTWeen.To(object.transform, 1.0f, new TweenParms().Prop("prop," value).Prop(etc)))

    basically using a TweenParms by adding .Prop and .Prop both transformation were applied during that sequence

    How can I achieve the same using DOTWeen? I can't find the same thing in the documentation, I just need sometimes to run multiple transformations at once inside a sequence, any help would be appreciated, thanks :)
     
  49. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,517
    Hi I have posted this issue :

    http://forum.demigiant.com/index.php?topic=1096.msg1787#msg1787

    at the official forum but it looks like it is not getting its attention.

    Can anyone help?

    "When I use DOGradientColor to tween material's color, it somehow goes all "wrong" and seems like it is making the alpha to shoot up rocket sky and make the shader to behave in a real strange way.

    I am using normal particle/additive shader and using it such way :

    colorTween0 = scanMaterial.DOGradientColor(colorGradient, "_TintColor" , 1);

    When it goes wrong, I tried to manually assign the color back by using inspector and color picker, and then magically "snaps" back to the better / normal way.

    On Unity 5.3.4.p5

    I have attached bugged screen shot and the texture source I am using.

    It looks like it is almost shooting up the alpha value so high that almost every non zero alpha pixel is lit as 100%"
     
  50. nkj79

    nkj79

    Joined:
    Jan 5, 2016
    Posts:
    2
    How can I do continuous rotation of a image using DOTween (not DOTweenPro) and getting best performance on mobile when 8-10 images will rotate at the same time.