Search Unity

DOTween (HOTween v2), a Unity tween engine

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

  1. GamePowerNetwork

    GamePowerNetwork

    Joined:
    Sep 23, 2012
    Posts:
    257
    I'm sorry if this has been asked before @Izitmee but the thread is really long.

    I have a 2D game and I just want to use the Tween Path component when the gameObject oriented to the path.. but I need rotation to only be constrained to the Z axis... if not the 2D gameObject disappears because it's rotating on X and Y also.
     
  2. pea

    pea

    Joined:
    Oct 29, 2013
    Posts:
    98
    Random thought: if there's a RigidBody attached to your GameObject, can you freeze the X and Y rotation? (checkboxes on the RigidBody component)
     
  3. GamePowerNetwork

    GamePowerNetwork

    Joined:
    Sep 23, 2012
    Posts:
    257
    Sadly that didn't work for me :-(
     
  4. songofhawk

    songofhawk

    Joined:
    Dec 14, 2014
    Posts:
    10
    Well, the result in my test is quite different:
    1. only when setting the index as 'x', the role get the right direction
    2. the last waypoint still trigger the event, so i must omit the last point, otherwise an exceed array boundary exception will be throw.
    This may caused by start point of my role, which is different with the first one in waypoints (wayPoints[0]).
     
  5. JakeTBear

    JakeTBear

    Joined:
    Feb 15, 2014
    Posts:
    123
    We must be using different versions of the package, that could explain this.
     
  6. JakeTBear

    JakeTBear

    Joined:
    Feb 15, 2014
    Posts:
    123
    @PyroStudios There is a special function to set constraints on the axis, take a look at the Tweener.SetOptions(), you want to modify AxisConstraints
     
    GamePowerNetwork likes this.
  7. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    Whew, sorry people, had kind of an incident and last week I was completely out. Many thanks to @JakeTBear again for the help!

    @dl_studios Sorry, that was for internal testing. I'm gonna post an official update to DOTween within the day which will remove the log.

    @Mr_Cad Target-based IsTweening works only if the tween was created using a shortcut (because shortcuts automatically store their target). When using the generic way, you can add the target as an ID, via SetId(sprite), and then IsTweening will work as you intended.

    @mambo_2 Hi! That is pretty cool! Though I'm sorry to say that the direction of a tween is determined by its parent Sequence, and there's no way to change that without big changes in both the architecture and the logic. Sequences should be considered like a composited video, where its children have no autonomy once the Sequence is rendered.

    @idurvesh As @zombiegorilla says, you can animate (either by tweening or animating) the same property only once at a time, because both systems use fixed values and will fight each other. The trick here would be to place your target inside a parent, so you can rotate the parent with one system, and the child with the other.
    EDIT (noticed your other reply). Since you're not animating rotation with both systems, there could still be a keyframe in the animator for rotation which is keeping it fixed?

    @sdviosx Delay can't be changed once it's set. I never thought there might be need for that. But inside your FireProjectile method you could simply tell the tween to start after the given delay, instead of adding the delay inside the tween itself, using DOVirtual.DelayedCall:
    Code (csharp):
    1.  
    2. public void FireProjectile ()
    3. {
    4.         if (moveTween.IsPlaying())
    5.             return;
    6.  
    7.         // Update values
    8.         moveTween.ChangeEndValue(fireDirection, duration);
    9.         // Actually fire after 0.5" of delay
    10.         DOVirtual.DelayedCall(0.5, DoFireProjectile, false);
    11. }
    12. public void DoFireProjectile()
    13. {
    14.         moveTween.Restart(true);
    15. }
    16.  
    @pea Weird, you should also get the error message there. Are you using the last version? Also, you can just disable safe-mode from DOTween's options, and those errors won't be caught anymore, and thus you'll get the full log (and also the full exception).
    EDIT: ahaha ok you already solved it in the next post :D
     
    JakeTBear likes this.
  8. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    NEW DOTWEEN UPDATE 1.1.030
    • NEW: Added Transform.DORotateQuaternion/DOLocalRotateQuaternion shortcuts
    • CHANGE: Sequence.Join now considers also Interval insertion time
    • BUGFIX: Fixed tweens for double values erroneously accepting float end values

    @dl_studios This removes the log :)
     
  9. GamePowerNetwork

    GamePowerNetwork

    Joined:
    Sep 23, 2012
    Posts:
    257
    Thanks @JakeTBear ... but are you saying that I can't just use the component in the editor? I have to do a SetOptions in code for every game object I want to constrain to the Z axis?

    Or is there some global settings I can change?
     
  10. JakeTBear

    JakeTBear

    Joined:
    Feb 15, 2014
    Posts:
    123
    @PyroStudios You can totally use the component in the editor, Izitmee created some callbacks hooks in the component which you can hook to do some extra setting up in code if needed to, the cool thing about the component is the visual aspect of placing the path nodes on the scene but nothing will ever replace the power of code :)

    You can also create a single mono behaviour that gets the path animation component and sets the options by default.

    Hope this helped!
     
    GamePowerNetwork likes this.
  11. Salgueiro157

    Salgueiro157

    Joined:
    Nov 23, 2012
    Posts:
    4
    Is there a way of playing a tween on the editor? I wanted to test some animations but don't want to play the scene to actually see it.
     
  12. GamePowerNetwork

    GamePowerNetwork

    Joined:
    Sep 23, 2012
    Posts:
    257
    That does help! thanks a lot!
     
    JakeTBear likes this.
  13. ikazrima

    ikazrima

    Joined:
    Feb 11, 2014
    Posts:
    320
    I'm trying to use the shortcut for Textmesh Pro, but it is throwing this error:

    My code:
    Code (CSharp):
    1. ShortcutExtensionsTextMeshProUGUI.DOText(TMPText.text, _duration, _richText, mode, null);
    Looking at the docs, it clearly shows 5 arguments. What I might have missed?
     
  14. FyreDogStudios

    FyreDogStudios

    Joined:
    Aug 23, 2015
    Posts:
    97
    Hello! Is there a way to set DOtweenPath waypoints in code?
     
  15. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    @Salgueiro157 Hi! Sorry but there's no way to see the tweens without playing the scene.

    @ikazrima You might be using an older version of DOTweenPro (I changed the Scramble system recently). Get the latest version by following the instructions, so you can access the private downloads (the Asset Store is very slow to upload).

    @FyreDogStudios Sure, but you have to create the full tween via code, using the DOPath API.
     
    Last edited: Oct 31, 2015
  16. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    NEW DOTWEEN UPDATE v1.1.050

    NEW: Added Flash, InFlash, OutFlash, InOutFlash eases for flashing effects (works with all tweens and all properties)

    This is pretty cool if I may say so. Check this gif to understand it better, or see the docs about it.

    dotween_easeflash.gif
     
    pea and JakeTBear like this.
  17. jprocha101

    jprocha101

    Joined:
    Apr 8, 2015
    Posts:
    134
    Demigiant likes this.
  18. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    @jprocha101 That looks very cool! I can't try it out right now, because my phone is kind of running on coal at the moment, but the graphics look very cool! Congrats! :)
     
    jprocha101 likes this.
  19. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    NEW DOTWEEN UPDATE v1.1.060
    • NEW: Added Flash, InFlash, OutFlash, InOutFlash eases for flashing effects
    • NEW: Added period parameter to Flash, InFlash, OutFlash, InOutFlash eases
    This update replaces the previous one and improves A LOT on the new Flash ease. Now you can set a period parameter which will increase or decrease the flashing in time. Way more cool and useful :)

    Check out the gif here and/or the docs.

    dotween_easeflash.gif
     
    garrido86 and jprocha101 like this.
  20. FyreDogStudios

    FyreDogStudios

    Joined:
    Aug 23, 2015
    Posts:
    97
    Hey, is there are way to check if a DOtweenPath has finished?
     
  21. FyreDogStudios

    FyreDogStudios

    Joined:
    Aug 23, 2015
    Posts:
    97
    Nevermind, I didn't see the events. I got it.
     
  22. Landci

    Landci

    Joined:
    Aug 28, 2012
    Posts:
    33
    hello i am getting this error randomly, and i cannot really reproduce it:

    DOTWEEN :: An error inside a tween callback was silently taken care of > Argument is out of range.
    Parameter name: index
    UnityEngine.Debug:LogWarning(Object)
    DG.Tweening.Core.Debugger:LogWarning(Object) (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__DOTween/_DOTween.Assembly/DOTween/Core/Debugger.cs:26)
    DG.Tweening.Tween:OnTweenCallback(TweenCallback) (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__DOTween/_DOTween.Assembly/DOTween/Tween.cs:269)
    DG.Tweening.Tween:DoGoto(Tween, Single, Int32, UpdateMode) (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__DOTween/_DOTween.Assembly/DOTween/Tween.cs:251)
    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)

    any hint on what that could be??
     
  23. pea

    pea

    Joined:
    Oct 29, 2013
    Posts:
    98
    Hi @Landci. That's an issue in one of your callback functions. Newer versions of DOTween provide more information with these errors. Or, you can just disable safe-mode from DOTween's options, and those errors won't be caught anymore, and thus you'll get the full log (and also the full exception) from the error in your callback function.
     
  24. BTStone

    BTStone

    Joined:
    Mar 10, 2012
    Posts:
    1,422
    Hey @Izitmee
    do you think you might add something "ScaleHeight" and "ScaleWidth" for Unity UI Images/Objects for the Animation-Component?
     
  25. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    @BTStone Hiya! Added to my todo list. Tomorrow I'm completing a very silly pilot for a prototype, and I hope the next day to be working on this feature. A question in the meantime: I would add simply Scale, ok? So you can scale both?
     
    BTStone likes this.
  26. BTStone

    BTStone

    Joined:
    Mar 10, 2012
    Posts:
    1,422
    Would be nice if it be basically the same like the current Scale-Animation-Tween with the option to uniform scale or individually :3
     
  27. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    Absolutely! Will do :)
     
    BTStone likes this.
  28. BTStone

    BTStone

    Joined:
    Mar 10, 2012
    Posts:
    1,422
    Much love <3
     
  29. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    NEW DOTWEEN PRO UPDATE v0.9.380 (private forum link)

    New Features:
    • Scripting > DOGradientColor shortcut for tk2dSprite objects
    • DOTweenAnimation/Path > Added option to set it as SpeedBased
    • DOTweenAnimation > Added UIWidthHeight tween, which changes the Width/Height of a UI object
    • DOTweenAnimation > Added Light tweens. You can now use Fade and Color to tween a light's intensity and color
    • DOTweenAnimation > Fade now works also with CanvasGroup objects
    • DOTweenAnimation > Move tweens > Added option to use a target as an end value (beware: this doesn't create a follow tween, but simply takes the target's position at startup and uses it as the end value)
    • DOTweenPath > Option to choose UpdateType
    • DOTweenPath > Added GetDrawPoints method, which can be used in the editor to get the draw points of the path (beware, those are NOT the same as the waypoints)
    Bugfix:
    • DOTweenAnimation > Using a move target now works correctly with UGUI elements too

    @BTStone Voila ;)
     
    pea and BTStone like this.
  30. BTStone

    BTStone

    Joined:
    Mar 10, 2012
    Posts:
    1,422
    Oh, wow, that was quick :D
    Works like a charm!
     
  31. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
  32. kobyle

    kobyle

    Joined:
    Feb 23, 2015
    Posts:
    92
    Hey man,

    My game is now published, and I have been getting pretty much exceptions with the following message:

    NullReferenceException UnityEngine.Transform.get_position () DG.Tweening.ShortcutExtensions+<>c__DisplayClass39_0.<DOMoveY>b__0 () DG.Tweening.Plugins.Vector3Plugin.EvaluateAndApply (VectorOptions options, DG.Tweening.Tween t, Boolean isRelative, DG.Tweening.Core.DOGetter`1 getter, DG.Tweening.Core.DOSetter`1 setter, Single elapsed, Vector3 startValue, Vector3 changeValue, Single duration, Boolean usingInversePosition, UpdateNotice updateNotice) DG.Tweening.Core.TweenerCore`3[UnityEngine.Vector3,UnityEngine.Vector3,DG.Tweening.Plugins.Options.VectorOptions].ApplyTween (Single prevPosition, Int32 prevCompletedLoops, Int32 newCompletedSteps, Boolean useInversePosition, UpdateMode updateMode, UpdateNotice updateNotice) DG.Tweening.Tween.DoGoto (DG.Tweening.Tween t, Single toPosition, Int32 toCompletedLoops, UpdateMode updateMode) DG.Tweening.Core.TweenManager.Goto (DG.Tweening.Tween t, Single to, Boolean andPlay, UpdateMode updateMode) DG.Tweening.Sequence.ApplyInternalCycle (DG.Tweening.Sequence s, Single fromPos, Single toPos, UpdateMode updateMode, Boolean useInverse, Boolean prevPosIsInverse, Boolean multiCycleStep) DG.Tweening.Sequence.DoApplyTween (DG.Tweening.Sequence s, Single prevPosition, Int32 prevCompletedLoops, Int32 newCompletedSteps, Boolean useInversePosition, UpdateMode updateMode) DG.Tweening.Sequence.ApplyTween (Single prevPosition, Int32 prevCompletedLoops, Int32 newCompletedSteps, Boolean useInversePosition, UpdateMode updateMode, UpdateNotice updateNotice) DG.Tweening.Tween.DoGoto (DG.Tweening.Tween t, Single toPosition, Int32 toCompletedLoops, UpdateMode updateMode) DG.Tweening.Core.TweenManager.Update (UpdateType updateType, Single deltaTime, Single independentTime) DG.Tweening.Core.DOTweenComponent.Update () GoogleAnalyticsV3:HandleException(String, String, LogType) UnityEngine.Application:CallLogCallback(String, String, LogType, Boolean)

    I get it with Google Analytics, but have no more information about what the cause of this error.
    It seems it happens on Android devices, but not on iOS ones...

    Do you have any thoughts where this might come from?

    Thanks,
    Koby
     
  33. CryoWraith

    CryoWraith

    Joined:
    Apr 3, 2013
    Posts:
    7
    Hi @Izitmee,
    Been having a problem with my iOS build, which wasn't showing up in my editor until I turned off Safe Mode. The error came from a (bunch of) infinite looping sequence that punch the scale of a transform. When the transform is destroyed (to be exact, its parent was destroyed), these errors pop out which says "The object of type 'Transform' has been destroyed but you are still accessing it."

    Code (csharp):
    1.  
    2. sequence = DOTween.Sequence();
    3.        
    4.         sequence
    5.             .Append(transform.DOPunchScale(Vector3.one * 0.5f, 0.5f, 10, 0f))
    6.                 .AppendInterval(1f)
    7.                 .SetLoops(-1, LoopType.Restart)
    8.                 .SetTarget(transform);
    9.  
    I tried to kill the sequence inside OnDestroy of the script, but it is still not working. Tried 3 ways to kill it, still having error.

    Code (csharp):
    1.  
    2.     void OnDestroy()
    3.     {
    4.         DOTween.Kill(transform);
    5.         transform.DOKill();
    6.         sequence.Kill();
    7.     }
    8.  
     
  34. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    @kobyle Hiya! That is due to your tween's target becoming NULL while the tween is playing. Are you using safe mode? If not, you should kill the tween when your target is destroyed.
    P.S. on iOS safe mode works only under given conditions (see what I wrote below).

    @CryoWraith Hi! Safe Mode works on iOS only if stripping level is set to "Strip Assemblies" or Script Call Optimization is set to "Slow and Safe" (because otherwise iOS removes all try-catch blocks, so there's no decent way to capture exceptions). Your solution is right, but only the third way will work (because Sequences are not assigned a target automatically). If that doesn't, it means that there must be some other transform or tween with the same issue.
     
  35. kobyle

    kobyle

    Joined:
    Feb 23, 2015
    Posts:
    92
    Heya,

    It doesnt happen at all on iOS.
    I do use safe mode on android, also it doesnt happen on every android device, only on some of them.

    Any clue how to proceed troubleshooting it?
     
  36. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    Oh sorry, you mentioned it wasn't happening on iOS and I misread.

    Mhmm that really puzzles me then. The exception is clearly sent because of a Transform's being NULL while checking its position, but that is something the safe mode takes care of without any problems.

    If you want to be sure this doesn't happen, you should manually kill all tweens on a transform when it's destroyed.

    Still, I'd like to understand why the safe mode is not working there. On what devices is this happening, statistically? Very old ones? Very new ones?
     
  37. CryoWraith

    CryoWraith

    Joined:
    Apr 3, 2013
    Posts:
    7
    Well, apparently OnDestroy does not fire if that game object was never active before it was destroyed. It is solved now. Thanks.
     
  38. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    Oh I had no idea, shame on me, but that makes sense.
     
  39. JayJennings

    JayJennings

    Joined:
    Jun 24, 2013
    Posts:
    184
    Trying to use DOTween in Javascript (client wants it; don't yell at me for not using c#) and thought this is what I'd need:

    importDG.Tweening;

    But I'm getting this error: Namespace 'DG.Tweening' not found, maybe you forgot to add an assembly reference?

    I've done searches on the DOTween site, this thread, and the entire internet in general, but can't find any JS examples. :)

    Any ideas?

    Jay
     
  40. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    did you add a space between import and DG.Tweening; ?
     
  41. JayJennings

    JayJennings

    Joined:
    Jun 24, 2013
    Posts:
    184
    Yeah, that was just a typo here.

    Jay
     
  42. JayJennings

    JayJennings

    Joined:
    Jun 24, 2013
    Posts:
    184
    Good freaking grief...

    I guess it works fine if you decide to actually import DOTween first before writing the code that calls it.

    Jay
     
  43. ababab5

    ababab5

    Joined:
    Apr 15, 2014
    Posts:
    508
    Hi,

    Your forum is down... :(
     
  44. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    Smart thinking there! :D
    P.S. Note though that all the shortcuts won't work with JS, because they're extension methods, so you'll have to use the generic way.

    @ababab5 Fixed, it's up again. Though something strange happened and I'm investigating
     
  45. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    Hi! Nope it's not, and sends the tween where it would be at the given time you pass it, considering its speed-based-ness.
     
  46. CryoWraith

    CryoWraith

    Joined:
    Apr 3, 2013
    Posts:
    7
    I never could get Sequence.Join to work, or am I misunderstanding how it works?

    Code (CSharp):
    1. DOTween.Sequence()
    2.                 .Append(testTransform.DOMoveY(600f, 2f))
    3.                     .Append(testTransform.DOMoveY(0f, 2f))
    4.                     .Join(testTransform.DOScale(2f, 2f));
    I'm expecting the scaling tween to be done when transform is moving towards 0f. But instead it is scaling when it is moving towards 600f. A guess would be all Joins are inserted at time = 0f, or am I doing something wrong here?
     
  47. robin-gallimard

    robin-gallimard

    Joined:
    Feb 2, 2015
    Posts:
    6
    Hi,

    Is it possible to create a custom Ease function?
    The online documentation mentions that it's possible but I haven't found any examples online (I'll admit I haven't read through the 39 pages of this thread). I assume it's just a question of adding an evaluation function in the EaseManager but there's probably a "proper way" to do it.

    Thanks !
     
  48. pea

    pea

    Joined:
    Oct 29, 2013
    Posts:
    98
    @CryoWraith, I think you mean to use "Insert" instead of "Join".

    From the documentation:

    Insert: Inserts the given tween at the given time position, thus allowing you to overlap tweens instead of just placing them one after each other.

    Join: Inserts the given tween at the same time position of the last tween or callback added to the Sequence.
     
    Demigiant likes this.
  49. pea

    pea

    Joined:
    Oct 29, 2013
    Posts:
    98
    @robin.gallimard: Yes, it's definitely possible. There's some info here.

    P.S.: A really handy way to quickly do a custom ease is to use an AnimationCurve. You can simply expose a public variable of type "AnimationCurve". Then you edit it on your script instance in the Unity Editor and apply it to the tweens in your code. Might not be applicable to your scenario, but thought I'd mention none the less.
     
    Last edited: Nov 10, 2015
    robin-gallimard and Demigiant like this.
  50. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    Honor to @pea for the answers! Thanks! :)

    Just an addition, about custom ease functions. While using an AnimationCurve is definitely the easiest way to go (because creating custom ease functions is definitely not an easy job), if you really want a custom ease function the EaseFactory example is maybe even too much, because that actually applies an ease to an ease. Instead, you just have to pass an EaseFunction delegate to SetEase. For example:
    Code (csharp):
    1. // Custom ease function
    2. // Must return a value between 0 and 1
    3. public float MyLinearEase(float time, float duration, float overshootOrAmplitude, float period)
    4. {
    5.     return time / duration;
    6. }
    7.  
    8. public void CreateATween()
    9. {
    10.    myTransform.DOMoveX(2, 1).SetEase(MyLinearEase);
    11. }