Search Unity

DOTween (HOTween v2), a Unity tween engine

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

  1. Galaks

    Galaks

    Joined:
    Feb 8, 2016
    Posts:
    12
    Hi,
    I made this script to skake my camera :

    public class ShakeCamera : MonoBehaviour {

    public Camera currentCamera;

    public float duration = 1f;
    public Vector3 strength = new Vector3(3, 3, 3);
    public int vibrato = 10;
    public float randomness = 90f;

    void Start () {
    }

    public void Shake(){

    currentCamera.DOShakePosition(duration, strength, vibrato, randomness);
    }

    }


    The camera reference is passed throught editor, the script works aswell when I call it but I get this error :

    transform.localPosition assign attempt for 'Main Camera' is not valid. Input localPosition is { NaN, NaN, NaN }.
    UnityEngine.Transform:set_localPosition(Vector3)
    DG.Tweening.<>c__DisplayClass11_0:<DOShakePosition>b__1(Vector3) (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__DOTween/_DOTween.Assembly/DOTween/ShortcutExtensions.cs:143)
    DG.Tweening.Plugins.Vector3ArrayPlugin:EvaluateAndApply(Vector3ArrayOptions, Tween, Boolean, DOGetter`1, DOSetter`1, Single, Vector3[], Vector3[], Single, Boolean, UpdateNotice) (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__DOTween/_DOTween.Assembly/DOTween/Plugins/Vector3ArrayPlugin.cs:136)
    DG.Tweening.Core.TweenerCore`3:ApplyTween(Single, Int32, Int32, Boolean, UpdateMode, UpdateNotice) (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__DOTween/_DOTween.Assembly/DOTween/Core/TweenerCore.cs:175)
    DG.Tweening.Tween:DoGoto(Tween, Single, Int32, UpdateMode) (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__DOTween/_DOTween.Assembly/DOTween/Tween.cs:238)
    DG.Tweening.Core.TweenManager:Update(UpdateType, Single, Single) (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__DOTween/_DOTween.Assembly/DOTween/Core/TweenManager.cs:391)
    DG.Tweening.Core.DOTweenComponent:Update() (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__DOTween/_DOTween.Assembly/DOTween/Core/DOTweenComponent.cs:50)

    So i don't understand why, can you help me please?
     
  2. juicybeast

    juicybeast

    Joined:
    Nov 12, 2014
    Posts:
    32
    Hello, sorry if this has been answered before, but I could not find the answer.

    I'd like to be able to tween or just change the values of an ongoing DOShake: the strength, vibrato and randomness. Any way to do that?
     
  3. Galaks

    Galaks

    Joined:
    Feb 8, 2016
    Posts:
    12
    I finally solved my problem. Thanks anyway
     
  4. sevensails

    sevensails

    Joined:
    Aug 22, 2013
    Posts:
    483
    Another problem... I have to restart my game after this one :

    Code (csharp):
    1.  
    2. IndexOutOfRangeException: Array index is out of range.
    3. DG.Tweening.Core.TweenManager.Despawn (DG.Tweening.Tween t, Boolean modifyActiveLists) (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__DOTween/_DOTween.Assembly/DOTween/Core/TweenManager.cs:217)
    4. DG.Tweening.Core.TweenManager.DespawnTweens (System.Collections.Generic.List`1 tweens, Boolean modifyActiveLists) (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__DOTween/_DOTween.Assembly/DOTween/Core/TweenManager.cs:821)
    5. DG.Tweening.Core.TweenManager.Update (UpdateType updateType, Single deltaTime, Single independentTime) (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__DOTween/_DOTween.Assembly/DOTween/Core/TweenManager.cs:399)
    6. DG.Tweening.Core.DOTweenComponent.Update () (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__DOTween/_DOTween.Assembly/DOTween/Core/DOTweenComponent.cs:50)
    7.  
     
  5. sirio21

    sirio21

    Joined:
    Mar 11, 2013
    Posts:
    114
    hi! i am new on dottween. Any way to scale or punch to up; with an anchor or pivot in Y axis. As a flower growth to up.
     
  6. 55hz

    55hz

    Joined:
    Nov 3, 2014
    Posts:
    1
    Hello and thanks for a great tool! We are running into a bit of a snag however. We have a mechanic in which the tempo of the level music controls the timing of various events and animations. I've been trying to set the "duration" parameter of a DOTweenAnimation component when the level is loaded, but it seems to not actually set the tweens with these values. We can play the animations when we need to with no issue, which is great, but we would also like to set the duration during runtime for dynamic tempo changes or if we ever need to change the tempo of the level slightly for whatever reason without having to manually reset all of our durations in the editor.

    Question: Is there a proper way of setting the duration of a DOTweenAnimation component via script?

    Here's what we've been trying:

    DOTweenAnimation anim;

    void Start()
    {
    anim = GetComponent<DOTweenAnimation>();
    anim.duration = calculateDuration();
    }

    // Called during tempo changes
    public void setAnimDuration()
    {
    anim.duration = calculateDuration();
    }

    float calculateDuration()
    {
    // ...
    }

    If I click "Activate Edit Mode" when I test the level, I can see that the value has been changed, but the actual tween is always run with whatever settings were in place prior to playing and they revert once I stop the game.

    We have developed a way of accomplishing this effect via script without using the DOTweenAnimation component and are currently using that method for prototyping, but the component is just so handy for triggering other events that we'd like to keep using it if possible.

    Thanks!
     
  7. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    Apologies for the delay dear people. Note to self, once and for all: when you think you got no support questions, it's just the forum that forgot to send you notifications. Though I have to admit it's my bad, because it happened various times already and I should know better, so really, apologies. Billions of thanks to @JakeTBear for the help in the meantime.

    @Wagenheimer That is a bug that has been reported a few times, even if very rarely, and it's the only one I never truly fixed (even if I thought so) because I can't find a way to reproduce it. If you could manage to create a sample project that replicates it and send it to me that would be wonderful. In the meantime, note that you can fix it by using SetTweensCapacity to such a high number that DOTween won't need to auto-increment the max tween/sequence capacity automatically (since that's what's causing all your bugs).

    @Furkann About your second issue, I suppose you're not using safe-mode? That happens if safe-mode is off and your target is destroyed while the tween is still running. You're not forced to use safe-mode obviously, but in that case you should take care to kill all tweens on a target when it's destroyed.

    @Tastman Ease on Sequences applies that ease to the whole Sequence, but doesn't change the inner tweens eases. Imagine your tweens, with their respective eases, as if they were a single movie clip. When you're changing a Sequence's ease (default is always Linear for Sequences, regardless of what you set in DOTween's Utility panel) you're applying that ease to the actual reproduction of that clip, not to the inner tweens.

    @Galaks That is weird, but it means that Unity can't assign the localPosition value of your camera. Can you replicate this in a barebone project and send it to me? Here everything works correctly so I can't replicate it myself. Also, on what Unity version are you?
    P.S. Oh, saw that you solved it after reading you first post. What was it?

    @Juicy Beast Shake is a fixed tween, so it can't be changed after creation I'm afraid.

    @sirio21 Hi! There is no way to change the default pivot on an object via DOTween, but the usual trick in this case is to place your object inside a parent, with the pivot you want, then tween the parent.

    @55hz Hi! In case of DOTweenAnimations, the tween is created during Awake, and after that the duration becomes fixed. The best way to do what you have in mind would be to set the Script Execution Order of DOTweenAnimations to be launched after the default time, so you can use your code's Awake to change the duration before it's applied.

    @Dragonic89 That is so weird :O I'm gonna investigate immediately!
     
    JakeTBear likes this.
  8. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    @Dragonic89 I discovered something. If you use Application.targetFrameRate everything works correctly. Still have no idea why captureFramerate (which does approximately the same thing) breaks stuff though.
     
  9. mrm83

    mrm83

    Joined:
    Nov 29, 2014
    Posts:
    345
    I have textmeshproui element, but DOText doesn't work.. it is not defined..

    Is there some setup that I must do for dotween to work with text mesh?

    update:
    i fixed it.. i had to reimport and setup again!
     
    Last edited: Feb 26, 2016
  10. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    @mrm83 Great! And yes, if you run DOTween's setup before TextMesh is imported, the extra libraries will be deleted, so that's why you have to import it again in order to update the setup.
     
  11. byerdelen

    byerdelen

    Joined:
    Mar 27, 2010
    Posts:
    68
    Hi @Izitmee,
    I am using your tween system in nearly any project and I can't tell how great DOTween is! Thank you for creating such wonderful tool.
    I have a need of paths in a project however it's the first time I use them. I want to create 10 paths as 10 gameobjects and I want to put them in an array of paths. Then I want to get the PathGetPoint() on that place and also the rotation. So I do not want to use them as tweens but as path editor.

    I want to use something like that:

    Code (CSharp):
    1.  
    2. public Tween myTween;
    3.  
    4.     void FixedUpdate ()
    5.     {
    6.      transform.position = myTween.PathGetPoint(place);
    7.      place += 0.001f;
    8.     }
    But I realised I cannot serialise Tweens or Paths. Also Paths can not be used seperately from tweens so I can get the position and rotation of specific percentage of a path.

    Is there any way to achieve such fashion on paths?

    Thanks
     
  12. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    @byerdelen Hi, and glad you like it!

    What you could do is to simply serialize the path as a Vector3 array. Then, at runtime, you create the paths, each of them tied to a tween, so you can use PathGetPoint on the tween and spam it around. I might be getting confused here, but that should work.
     
  13. Steelhound

    Steelhound

    Joined:
    Jan 10, 2014
    Posts:
    1
    Hi! I've just started to use DOTween and really like how comfortable it is to work with!

    Can you please advice what is the best way to make a MoveBy effect from iTween?
    In fact, I need a tween to make transform.translate effect with space.relativeTo = Space.Self.
    My transform can change it's position and rotation during this tween, due to parenting-unparenting other moving and rotating objects, but it should NOT affect it's own tweening - it should continue to move the given distance along it's own local axis.

    Thank you in advance!
     
  14. ldhongen1990

    ldhongen1990

    Joined:
    Dec 18, 2015
    Posts:
    61
    [BUG REPORT]

    Hello Izitmee,

    I found a bug in your DOTween shake function when used with the camera and a unity project containing the isolated bug has been attached for your debugging purposes.

    This bug only occurs in a Windows 8.1 metro build executable, running within the unity editor will NOT show the bug, so you will need to build a copy of the project targeting the windows store platform, SDK version 8.1.

    Apparently your shake tween will only work on several magical values for the duration parameter in the metro build. Initially my team and I suspected it is some floating point error problem but then it turns out the problem is rather undefined.

    The sample project will first showcase a working DOTween shake working as intended, and then a faulty one plugged with a duration value that it doesn't like.

    Please take a look at it and tell me what you think.

    Unity Version: 5.3.3p1
    DOTween Version: v1.1.135 [Release build]
     

    Attached Files:

  15. CGPepper

    CGPepper

    Joined:
    Jan 28, 2013
    Posts:
    152
    @Izitmee
    I have some trouble understanding how to change a value from the inspector component with code.


    I thought to grab the game object, get DOTweenAnimation script and do something like SetDelay(float), but no such method is present. How do i do it
     
  16. JakeTBear

    JakeTBear

    Joined:
    Feb 15, 2014
    Posts:
    123
    @CGPepper I see there is a field called "delay", give that a go? hope it helps!
     
    Demigiant likes this.
  17. darkLooter

    darkLooter

    Joined:
    Aug 31, 2015
    Posts:
    2
    hi @Izitmee

    Our team use dotween for a few months,dotween is the best!
    but some proplem is still puzzling me.

    1 : Array index is out of range

    its offen appear when there are two more tweener control the sprite. Like Two DoMove tweener some time, when excute the function transform.DoKill(),this error will show in few times.
    our group try to reproduce the problem in Certain occasion,but not success yet。

    [update]
    It just happened minute ago, a new gameobject in DolocalMove ,only one script control transform. code is
    Code (CSharp):
    1. transform.DOLocalMove(posistion, distance / speed).SetEase(Ease.Linear)
    this is the log
    int same time the 【DOTween】 component has the log
    2 I use

    Code (CSharp):
    1.     Tweener t = cubeA.DOMove(cubeB.position, 5f).SetSpeedBased();
    2.         t.OnUpdate(()=>{
    3.             t.ChangeEndValue(cubeB.position,5f,true);
    4.         });
    to make the bullet trace a moving target。

    but i have some question

    a) when cubeA catch the cubeB, a error 《 Position is { NaN, NaN, NaN }.》 be throwed。100% reproduce in dotween example。

    b ) in my game, question a) not appear very offen,but when the bullet catch the target,the tweener auto paused ,I set OnPause delegate function to confirm the bullet hit target,is it a good way?

    c ) In old code, I use distance<0.1f to check bullet hit,but when bullet appear position is too close to target(distance >0.1) the tweener just 1 update then paused,even have a little distance to get target postion。
    If bullet shot postion is far from target , this situation never happened。



    by the way my dotween version is 1.0.750. unity ver is 5.01.f3.

    Thank you and your Dotween.
     
    Last edited: Mar 5, 2016
  18. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    @Steelhound Hi, glad you find it comfortable.

    iTween's MoveBy is not implemented in DOTween, because it's a kind of animation that doesn't allow to be correctly rewinded (since it just adds values to its target and can't keep track of all the changes that might happen). The usual trick in this case is to place your tweened target inside a parent, then rotate and displace the parent while tweening the child's localPosition, so that it will always follow the parent's orientation.

    @CGPepper Most DOTweenAnimation properties can't be changed at runtime, since once the tween is created they're locked. That said, there is a trick. As @JakeTBear correctly said, you have to access the "delay" property of the DOTweenAnimation and change that, but you have to do that BEFORE the DOTweenAnimation component actually creates the tween. That happens in the first Awake call. So you either have to disable the DOTweenAnimation component, and at runtime change the delay then enable it, or use Script Execution Order to be sure your script's Awake call will run before DOTweenAnimation's.

    @darkLooter Hi! Your first issue can be solved like this. But if you manage to reproduce it and send it to me it would be great, so I can check it, since I was never able to reproduce it myself.
    About your second issue, can you update to the latest DOTween version (1.1.135) and see if it fixes it?
    Let me know.

    @ldhongen1990 That is very weird. I can't make Windows Metro builds, but I'm checking your project and trying to see what might be happening. Can you download the hyper-compatible version and let me know if the bug still happens? No need to change code: just overwrite the DOTween files with the hyper-compatible ones and re-run the setup.
     
  19. darkLooter

    darkLooter

    Joined:
    Aug 31, 2015
    Posts:
    2
    dear @Izitmee

    Very thank you, I must give you a wonder kiss.

    First issue Just like you said, the Capacity make this happend. And its our faults.

    One of us use a pause tweener in camera move。But he didnt kill it after operation

    the code like this
    Code (CSharp):
    1. if (touches[0].phase == TouchPhase.Began)
    2.                 {
    3.                     _dragPoint = touches[0].position;
    4.                     DOTween.Pause(_camera.transform);
    so every touch or click will left a pause state tweener. when tweener count == default capacity,we got the array error。

    [update ] reproduce way(capacity 199/200)
    when operation is click ,never reproduce。

    when operation is camera move,offen happen

    we try to find must happen way,but it will take some times,if we found will post to you。

    --------------------------------------------------------------------------***************
    second issue I upgrade to version 1.1.135 And the second issue no change。

    I wrote test code :
    Code (CSharp):
    1.     Tweener t = ca.DOMove(cb.position, 1f).SetSpeedBased();
    2.  
    3.         t.OnUpdate(() => t.ChangeEndValue(cb.position, 1f, true));
    And the error :


    And In our game environment ,second issue sub c) still exist,report here
    upload_2016-3-5_19-29-19.png
    when skill destroy the count not minus but all null
     
    Last edited: Mar 5, 2016
  20. bryanlewis

    bryanlewis

    Joined:
    Jan 13, 2013
    Posts:
    3
    Hi! While using the awesome DOTween Pro package in my game, I got this surprising message today.

    DOTWEEN :: Error in RemoveActiveTween.totActiveSequences. It's been taken care
    of so no problems, but Daniele (DOTween's author) is trying to pinpoint it and
    it would be awesome if you could reproduce this log in a sample project and
    send it to him. Or even just write him the complete log that was generated by
    this message. Fixing this would make DOTween slightly faster. Thanks.

    Nicely done message! Now I'm trying to reproduce the problem for you. I can rep it easily in my full-blown game but not in a small project that I can send. The sequence that caused it was like: A tween's OnComplete calls a callback method, which creates a sequence which calls another callback OnUpdate. The OnUpdate method does DOTween.KillAll(). I tried that in a small test project with this script attached to a cube:
    Code (csharp):
    1.  
    2. public class TestDOTween : MonoBehaviour
    3. {
    4.     void Start()
    5.     {
    6.         transform.DOLocalMoveX(2f, 1f)
    7.                 .SetLoops(2, LoopType.Yoyo)
    8.                 .SetEase(Ease.Linear)
    9.                 .OnComplete(CompleteCallback);
    10.     }
    11.  
    12.     void CompleteCallback()
    13.     {
    14.         Sequence seq = DOTween.Sequence();
    15.         seq.Append(transform.DOMoveY(4f, 1f)
    16.                             .SetLoops(20, LoopType.Yoyo)
    17.                             .SetEase(Ease.InBack)
    18.                             .OnUpdate(CheckCallback));
    19.     }
    20.  
    21.     int loopsDone = 0;
    22.  
    23.     private void CheckCallback()
    24.     {
    25.         loopsDone++;
    26.         if (loopsDone > 40) {
    27.             Debug.Log("CheckCallback killing tweens");
    28.             DOTween.KillAll();
    29.             StopAllCoroutines();
    30.             Debug.Log("CheckCallback done");
    31.         }
    32.     }
    33. }
    34.  
    Unfortunately the error doesn't happen, even though the script is doing everything my bigger project was doing as far as I can see. Here's the log I got when it did happen:

    CheckCallback killing tweens
    0. PlayerHead.CheckCallback() at .../Scripts/PlayerHead.cs:362
    1. DG.Tweening.Tween.OnTweenCallback() at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__DOTween/_DOTween.Assembly/DOTween/Tween.cs:272
    2. DG.Tweening.Tween.DoGoto() at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__DOTween/_DOTween.Assembly/DOTween/Tween.cs:242
    3. DG.Tweening.Core.TweenManager.Goto() at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__DOTween/_DOTween.Assembly/DOTween/Core/TweenManager.cs:565
    4. DG.Tweening.Sequence.ApplyInternalCycle() at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__DOTween/_DOTween.Assembly/DOTween/Sequence.cs:305
    5. DG.Tweening.Sequence.DoApplyTween() at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__DOTween/_DOTween.Assembly/DOTween/Sequence.cs:239
    6. DG.Tweening.Sequence.ApplyTween() at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__DOTween/_DOTween.Assembly/DOTween/Sequence.cs:143
    7. DG.Tweening.Tween.DoGoto() at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__DOTween/_DOTween.Assembly/DOTween/Tween.cs:238
    8. DG.Tweening.Core.TweenManager.Update() at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__DOTween/_DOTween.Assembly/DOTween/Core/TweenManager.cs:391
    9. DG.Tweening.Core.DOTweenComponent.Update() at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__DOTween/_DOTween.Assembly/DOTween/Core/DOTweenComponent.cs:50

    Then your DOTWEEN error message appeared with this trace:

    0. DG.Tweening.Core.Debugger.Log() at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__DOTween/_DOTween.Assembly/DOTween/Core/Debugger.cs:22
    1. DG.Tweening.Core.Debugger.LogRemoveActiveTweenError() at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__DOTween/_DOTween.Assembly/DOTween/Core/Debugger.cs:70
    2. DG.Tweening.Core.TweenManager.RemoveActiveTween() at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__DOTween/_DOTween.Assembly/DOTween/Core/TweenManager.cs:871
    3. DG.Tweening.Core.TweenManager.Update() at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__DOTween/_DOTween.Assembly/DOTween/Core/TweenManager.cs:401
    4. DG.Tweening.Core.DOTweenComponent.Update() at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__DOTween/_DOTween.Assembly/DOTween/Core/DOTweenComponent.cs:50

    Hope this helps.
    Bryan
     
    Last edited: Mar 5, 2016
    Demigiant likes this.
  21. moh05

    moh05

    Joined:
    Nov 26, 2015
    Posts:
    65
    Hello everyone,

    Hope all is well :)

    I am a developer in Kuwait and was wondering about whether the tool is "mobile -performance" friendly when it comes to tweening UI elements.

    Basically I have a canvas set to World Render mode and I need to to move/rotate/scale cards ( using z value too). Did anyone tried something similar?

    Thanks in advance for your support.

    Regards,

    Mohamad Hindi
     
  22. lucastrvsn

    lucastrvsn

    Joined:
    Sep 30, 2015
    Posts:
    5
    Hello, @Izitmee

    Rotate is imprecise? I'm trying to rotate my character by 90 and 90 degrees. And, in the second try (init from 0) it gives 180,701.. and continues. How do I fix that?

    Code (CSharp):
    1. private void SwipeRightCallback(Gesture gesture)
    2.     {
    3.         if (timeToRotate > 0.15f && gesture.state == GestureState.ENDED)
    4.         {
    5.             transform.DOLocalRotate(new Vector3(0f, 90f, 0f), 0.1f, RotateMode.LocalAxisAdd);
    6.             timeToRotate = 0f;
    7.         }
    8.     }
    Thanks! :D

    -- edit
    Forget, I fixed! :D
     
    Last edited: Mar 8, 2016
  23. ldhongen1990

    ldhongen1990

    Joined:
    Dec 18, 2015
    Posts:
    61

    Hello Izitmee,

    The bug is still present, even after I have replaced my dotween with the hyper-compatible version.
    Please look into it.

    Thanks
     
  24. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    @darkLooter Got it! It 's because you're using SetSpeedBased, and when both targets coincide the speed-based duration is 0, which leads to errors. I could fix this, but it would require some checks inside the tween manager which would slightly slow down the engine. Considering this is a fringe case (because you shouldn't create 0-duration tweens), I'd recommend fixing it on your side, which would be much more efficient. Just add a check to prevent the update if the targets coincide:
    Code (csharp):
    1.  
    2. t.OnUpdate(()=> {
    3.    if (ca.position != cb.position) t.ChangeEndValue(cb.position, 1f, true);
    4. });
    5.  
    @bryanlewis Thanks for helping! :) Unfortunately that issue is really hard to reproduce, as you saw yourself. I'm gonna investigate your log to see if it helps in the meantime.

    @moh05 Already answered via mail, but I'm gonna write a couple lines here too for other users. When moving UI objects, always use anchoredPosition, because using a UI transform's position directly requires Unity to recalculate a lot of things at each change.

    @furle Ah damn, I saw you fixed it only after I made some tests :D Everything works correctly here, so I suppose it was something else.

    @ldhongen1990 Damn! Ok gonna investigate more.
     
  25. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    @ldhongen1990 Hey, can I ask you to make an additional test? Do you still have the same issue if you use the camera as the tween target (which applies some extra stuff specific to the camera)?
    Code (csharp):
    1. transform.GetComponent<Camera>().DOShakePosition(3f, 1f); // etc
     
  26. ldhongen1990

    ldhongen1990

    Joined:
    Dec 18, 2015
    Posts:
    61
    Hello Izitmee,

    I tried out your suggestion by replacing transform.DOShakePosition with camera.DOShakePosition with the same codebase but the issue is still occuring.

    Let me know what you think.

    Cheers!
     
  27. RolfBertram_dot_me

    RolfBertram_dot_me

    Joined:
    Mar 1, 2011
    Posts:
    128
    Error when trying to Built for iOS: (I just installed DOTween, using with NodeCanvas)

    Plugin 'DOTween.dll' is used from several locations:
    Assets/Demigiant/DOTween/DOTween.dll would be copied to <PluginPath>/DOTween.dll
    Assets/NodeCanvas/Tasks/Actions/Tween/DOTween/DOTween.dll would be copied to <PluginPath>/DOTween.dll
    Please fix plugin settings and try again.

    UnityEditor.Modules.DefaultPluginImporterExtension:CheckFileCollisions(String)
    UnityEditorInternal.PluginsHelper:CheckFileCollisions(BuildTarget) (at /Users/builduser/buildslave/unity/build/Editor/Mono/Plugins/PluginsHelper.cs:25)
    UnityEditor.HostView:OnGUI()
     
  28. JakeTBear

    JakeTBear

    Joined:
    Feb 15, 2014
    Posts:
    123
    @RolfBertram.com Thats because DOTween already comes in Nodecanvas, make sure to delete the dll from nodecanvas before installing DOTWeen.
     
    Demigiant likes this.
  29. HeartofTheForce

    HeartofTheForce

    Joined:
    Sep 22, 2014
    Posts:
    1
    Hello,

    I am having some trouble with 0 duration tweens and PlayBackwards.

    Calling PlayBackwards on a completed 0 duration tween (with AutoKill set to false) will not play it backwards instead it will remain at it's current value.

    Code (CSharp):
    1.  mytween = transform.DOMoveX(100, 0f).SetAutoKill(false);
    is the example i'm currently using to test it and simply reversing it in an update method.
     
  30. CGPepper

    CGPepper

    Joined:
    Jan 28, 2013
    Posts:
    152
    Is it only possible to manipulate Text Mesh Pro through scripting?
    I am trying to set it up through the inspector, but components like Text are not found
     
  31. daisySa

    daisySa

    Joined:
    Dec 29, 2011
    Posts:
    341
    I've been using DOTween Pro since last year without any issues.

    I've just reverted to Unity 5.3.2p1 (from 5.3.3p1) and DOTween produced errors. I deleted/reinstalled the latest version (and applied the setup), and I'm getting several compiler errors in DOTweenAnimationInspector (attached).

    Any ideas? My workaround is to just delete that script.
     

    Attached Files:

    Last edited: Mar 10, 2016
  32. Ant1m3tas

    Ant1m3tas

    Joined:
    Feb 24, 2015
    Posts:
    4
    Hello.

    Is it possible to use PathGetPoint () in edit mode somehow?
    My goal is to be able to lock movement of objects by tween path in edit mode.
     
  33. D3ntrax

    D3ntrax

    Joined:
    Mar 21, 2014
    Posts:
    35
    @Izitmee

    Hey, I use this code for bounce my tiles. It's working but i don't like it. How can i change this code like a CandyCrush bounce effect ? (with use : moveVelocity, moveDirection, bouncePower, bounceStiffness variables.)

    Thanks...

    Code (CSharp):
    1.     public IEnumerator ApplyTileBounceEffect(float bounceStiffness, float bouncePower, float firstBounceBackFactor = 0.4f) {
    2.       if (!this.fallBounceAnimEnabled) {
    3.       this.fallBounceAnimEnabled = true;
    4.       if (NormalTile.OnStartTileImpactBounce != null) {
    5.       NormalTile.OnStartTileImpactBounce.Invoke(this);
    6.       }
    7.       this.fallBounceAnimTweener1 = transform.DOLocalMove(Vector3.up * bouncePower + [B]transform.position[/B], bounceStiffness).SetEase(Ease.OutExpo);
    8.       if (NormalTile.fallBounceWait == null) NormalTile.fallBounceWait = new WaitForSeconds(bounceStiffness * firstBounceBackFactor);
    9.       yield return NormalTile.fallBounceWait;
    10.       this.fallBounceAnimTweener2 = transform.DOLocalMove(transform.localPosition, bounceStiffness).SetEase(Ease.OutBounce).OnComplete(delegate {
    11.       this.fallBounceAnimEnabled = false;
    12.       });
    13.       }
    14.       yield break;
    15.       }
    16.  
     
  34. JakeTBear

    JakeTBear

    Joined:
    Feb 15, 2014
    Posts:
    123
    @HeartofTheForce This shouldnt work because tweens shouldnt have a 0 duration, simply thats not a tween but instead a set position, try to redesign your approach to "MoveForward" and "MoveBackwards" where you internally set the element position by its current position + your offset.

    @CGPepper Apparently, but you can make a component that would do what you want and use it everywhere :)

    @Furkann You can change your ease and the numbers in your tween, experiment until you achieve what you want.
     
    Demigiant likes this.
  35. bdovaz

    bdovaz

    Joined:
    Dec 10, 2011
    Posts:
    1,052
    @Izitmee on Wednesday Unity it's going to release 5.4 and it would be nice if you could change this:


    Now there is a "SceneManager.sceneLoaded" event that replaces that "magic" Monobehaviour method.
     
  36. garrido86

    garrido86

    Joined:
    Dec 17, 2013
    Posts:
    233
    I must be doing something wrong but the Rewind extension method doesn't work. Same for PlayBackwards.
    Is there something specific I need to prepare for getting Rewind to work?
     
  37. ikazrima

    ikazrima

    Joined:
    Feb 11, 2014
    Posts:
    320
    Hi there,

    I want to chain several speed-based tweens. Since sequences ignores SetSpeedBased, how do I chain them after each one has finished?
     
  38. FuguFirecracker

    FuguFirecracker

    Joined:
    Sep 20, 2011
    Posts:
    419
    Hi Hi
    Quick Q...

    Is it possible for a tween to fire off events at predefined values?

    Here's the scenario:

    I'm using DoTween to control the fillAmount of an image which I am using as a "power-up meter"
    .
    When the meter is 1/3 full [ 0.333f] I bestow a 2x score multiplier.
    When the meter reaches 2/3 full [0.666f] I bestow a 3x multiplier.

    Currently, I'm polling the fillAmount in OnUpdate()
    I would be much simpler, in my view, to subscribe to an event.
    Am I overlooking something obvious?


    Any suggestions on how to better handle this?
    Code to follow

    Thanks !

    Code (CSharp):
    1.         private int _scoreMultiple = 1;
    2.  
    3.         public void PowerDown(float drainSpeed)
    4.         {
    5.             PowerFluxTweener = PowerUpBarImage.DOFillAmount(0, drainSpeed).SetAutoKill(true);
    6.             PowerFluxTweener.OnUpdate(() => ManageMultiples(PowerUpBarImage.fillAmount));
    7.         }
    8.  
    9.         private void ManageMultiples(float fillAmount)
    10.         {
    11.             var lastMultiple = _scoreMultiple;
    12.  
    13.             if (fillAmount >= 0.666f)
    14.             {
    15.                 _scoreMultiple = 3;
    16.             }
    17.             else if (fillAmount >= 0.333f)
    18.             {
    19.                 _scoreMultiple = 2;
    20.             }
    21.             else
    22.             {
    23.                 _scoreMultiple = 1;
    24.             }
    25.  
    26.             if (lastMultiple == _scoreMultiple) return; // prevent Code what follows from executing EVERY update
    27.  
    28.             switch (_scoreMultiple)
    29.             {
    30.                 case 1:
    31.                     // fancy stuff goes here
    32.                     break;
    33.                 case 2:
    34.                     // fancier stuff...
    35.                     break;
    36.                 case 3:
    37.                     // superlatively fanciest
    38.                     break;
    39.  
    40.             }
    41.         }
     
  39. mikatu

    mikatu

    Joined:
    Aug 3, 2015
    Posts:
    28
    Hi,
    I also run into "Array index is out of range" error in my project and am able to reproduce it with this script
    Code (CSharp):
    1. using UnityEngine;
    2. using DG.Tweening;
    3.  
    4. public class BugHunt : MonoBehaviour {
    5.  
    6.     //void Start() { DOTween.SetTweensCapacity(2000, 100); }
    7.  
    8.     void tryTween() {
    9.         for (int i = 0; i < 50; i++)
    10.             transform.DOMove(new Vector3(1, 1), 0.5f);
    11.     }
    12.  
    13.     void Update() {
    14.         if (Input.GetKeyDown(KeyCode.Space)) {
    15.             for (int j = 0; j < 20; j++)
    16.                 DOVirtual.DelayedCall(0.1f * j, tryTween);
    17.         }
    18.     }
    19. }
     
  40. JakeTBear

    JakeTBear

    Joined:
    Feb 15, 2014
    Posts:
    123
    @ikazrima Hey, you can use the "OnComplete" callback and chain the tweens this way, I have done it myself and it works great.

    @FuguFirecracker This seems to be good, I think you are okay at least in that, maybe @Izitmee would have a better insight though :)

    @mikatu Those are potentially a lot of tweens being created and they have a considerable duration, you probably just running out of tweens objects (your commented code shows you already thought of this).

    Hope this helps!
     
    Demigiant and ikazrima like this.
  41. FuguFirecracker

    FuguFirecracker

    Joined:
    Sep 20, 2011
    Posts:
    419
  42. sathya

    sathya

    Joined:
    Jul 30, 2012
    Posts:
    297
    How to the remaining time of tween path from DoTweenPath ? Didn find anything helpful. Duration is set to speedBased
     
  43. ikazrima

    ikazrima

    Joined:
    Feb 11, 2014
    Posts:
    320
    Thanks @JakeTBear
    Though I'm already using OnComplete to check if my sequence have finish, I guess I can try to work something out with your suggestion ;)
     
  44. Seith

    Seith

    Joined:
    Nov 3, 2012
    Posts:
    755
    Hi @Izitmee I'm testing the latest 5.4 beta 10 and I'm getting a warning like this:



    Is that something you've addressed already in the latest DOTween version? Or do you still have to work on it?
     
  45. JakeTBear

    JakeTBear

    Joined:
    Feb 15, 2014
    Posts:
    123
    @ikazrima what I meant was to "not" use a sequence and use an OnComplete callback on each tween to start the next one, so once one completes you start the next one. I put mine in a list so I know I am done once the list has traversed completely for example.
     
    Demigiant likes this.
  46. ikazrima

    ikazrima

    Joined:
    Feb 11, 2014
    Posts:
    320
    @JakeTBear yes I understood what you said before, but maybe because of my wording it implied different :) but thanks again for your explanation.

    p/s : My previous attempt was to use 1 sequence, and add a OnComplete callback to check whether the whole tween is done.
    Using your way, I now know that I need to add a OnComplete callback to all to my different tweens, and on top of that add another 1 on the last tween to check whether the whole chain are completed.
     
  47. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    @HeartofTheForce As the masterful @JakeTBear said playing backwards a 0 duration tween is indeed something I never thought of, nor I thought would be useful. Can't you put the duration to like 0.001? That should work.

    @CGPepper Actually you can. But you have to FIRST import TextMeshPro and THEN run DOTween's setup, otherwise the TextMeshPro editor components will be removed. In your case, not that you have TMP, reimport DOTween completely and re-run the setup.

    @daisyDynamics That means you have some other asset/script in your project that is called TargetType, and that doesn't use namespaces (which is a mistake). In that case, the namespace-less asset/script doesn't allow any other asset/script to be called TargetType. If it's an asset, let me know the name and I'll contact the author to ask him to introduce namespaces, since they're pretty necessary for asset development.

    @Ant1m3tas Hi. I'm not sure what you mean. Can you explain me more?

    @N3uRo Uhm this is kind of a problem, because that would impari compatibility with older versions of Unity. Gonna find a way around it that doesn't use new API.

    @garrido86 Did you mark your tween with SetAutokill(false)? Because otherwise, when the tween completes it's killed, and any method (rewind, playbackwards, etc) won't work.

    @ikazrima Hi. You should calculate your duration manually (based on a speed-based logic) in that case and apply it to the tween.

    @FuguFirecracker Ahoy! OnUpdate is definitely the way to go. Adding a "warn me when x value is reached" inside DOTween would require it to check values every update, like you're doing now. But on the downside, it would also need to check if "there is any need to check" at every update, so it would make all tweens slightly slower.

    @mikatu Woah thank you! I was getting into that issue right now, because another user sent me a project that finally reproduces it, and your code is gonna help even more :)

    @sathya Hi. I'm not sure what you mean. If you want to know the time that has elapsed on a path tween, you can get a reference to the DOTweenPath (myDOTweenPath.GetTween()), and use that reference to get the elapsed time at any moment (myTween.Elapsed())

    @Seith Hey! Still didn't install the beta, but I see I'll have to find a workaround. For now you can ignore it since everything will work. But I'll soon find a workaround (that doesn't uses the new API because compatibility :p)

    @ldhongen1990 I made some tests in these days but can't find a reason why that's happening. In the meantime, a workaround would be to use OnComplete to set the shaked target's value to its correct position. By the way, did you check if this still happens with Unity 5.4 beta?
     
  48. sathya

    sathya

    Joined:
    Jul 30, 2012
    Posts:
    297
    I tried referencing DOTweenPath.GetTween() but it always throws a warning saying null reference handled internally. Even when tween is playing it shows the warning. I am not sure why GetTween retruns null
     
  49. tinyant

    tinyant

    Joined:
    Aug 28, 2015
    Posts:
    127
    I want to edit the DOTween path waypoint in play mode. How to do this?
    "Path editor is disable while in play mode."

    when Not in play mode. I want to call the Tween's function mytweenPath.GetTween().PathGetPoint(percent); It return Vector3.zero always.

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3. using DG.Tweening;
    4.  
    5.  
    6. [ExecuteInEditMode]
    7. public class CoolTweenEditor : MonoBehaviour
    8. {
    9.     // DOTween path.
    10.     public DOTweenPath tweenPath;
    11.     public Transform coolCube;
    12.     private double curTime = 0.0f;
    13.  
    14.     void OnEnable()
    15.     {
    16.         Debug.Log("@ execute in editor model:Start().");
    17.         this.tweenPath = GetComponent<DOTweenPath>();
    18.         UnityEditor.EditorApplication.update = MyEditorUpdateFunction;
    19.         curTime = UnityEditor.EditorApplication.timeSinceStartup;
    20.         this.tweenPath.GetTween().ForceInit();
    21.     }
    22.  
    23.     void MyEditorUpdateFunction()
    24.     {
    25.         this.Update();
    26.     }
    27.  
    28.     public float percent = 0.0f;
    29.     // Update is called once per frame
    30.     void Update()
    31.     {if (UnityEditor.EditorApplication.timeSinceStartup - this.curTime >= 4.0f)
    32.         {
    33.             // Debug.Log("@ play do tween path.");
    34.             if (this.tweenPath != null)
    35.             {
    36.                 Vector3 pos = this.tweenPath.GetTween().PathGetPoint(percent);
    37.                 coolCube.transform.position = pos;
    38.             }
    39.         }
    40.     }
    41. }
    I just want to make path preview function to my project, they can edit the wayPoint to change the Camera's position and so on.

    Thanks.
     
  50. tinyant

    tinyant

    Joined:
    Aug 28, 2015
    Posts:
    127
    I just want to make a slider to control the DOTween path process.When I drag the Slider I can get the current position in the path by slider's value.Not in play mode.Just like preview feature.
    But I always get Vector3.zero by call PathGetPoint().
    can anyone tell me why? or how to make a preview feature in Editor mode?

    Thanks~
     

    Attached Files:

    Last edited: Mar 17, 2016