Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

DOTween (HOTween v2), a Unity tween engine

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

  1. mimminito

    mimminito

    Joined:
    Feb 10, 2010
    Posts:
    780
    Hi,

    I am trying to play a Sequence forward, and then play it backwards when I need to. The PlayBackwards functionality seems to not be working for me. Below is the code I am using, what am I doing wrong? I am using the latest version on Unity 4.6.2.
    Code (CSharp):
    1. private Sequence mAnim;
    2.  
    3. private void SetupAnimSequence ()
    4. {
    5.     mAnim = DOTween.Sequence ();
    6.     mAnim.SetEase (Ease.Linear);
    7.     mAnim.Append (_SiteBackgroundImage.DOFade (1f, 0.5f));
    8.     mAnim.Insert (0, _TopBarTransform.DOAnchorPos (new Vector2 (0f, _TopBarTransform.anchoredPosition.y), 0.5f));
    9. }
    10.  
    11. private void AnimateSiteScreenIn ()
    12. {
    13.     mAnim.PlayForward();
    14. }
    15.  
    16. private void AnimateSiteScreenOut ()
    17. {
    18.     mAnim.PlayBackwards();
    19. }
     
  2. mimminito

    mimminito

    Joined:
    Feb 10, 2010
    Posts:
    780
    Figured out I need to set the AutoKill to false otherwise it kills it on completion! My bad for not realising that.
     
  3. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    Hiya all. First of all, major apologies for being late to reply. It's been/being a complicated time spent mostly in hospitals (not for myself) so work on the engine is delayed until next week.

    @eydamson_pugeh Sure you can, and it shouldn't affect your performance at all (it should actually make it better than controlling it with physics or frame by frame). Though I wouldn't recommend it to be honest. A character controller is usually best when controlled frame by frame instead than by animations, because it has to react to stuff very often.

    @Ben BearFish Your method would work with linear paths (which I suppose you used it with) but not with curved ones, where each curve is based on the position of previous waypoints. Or am I overlooking something? Let me know.

    @PhilllChabbb Yey emoticonman! :) You can use myTween.Elapsed/ElapsedPercentage to know where your tween is. If it's <= 0 it's rewinded.

    @neroziros I'm postponing the Pro since ages, shame on me. But since it's a payed asset my perfectionist side always wants to work on it a little more, plus I'm spending a looot of time on the free version. Maybe I should just wrap up something within next week and release it as a beta though. I'll honestly try to do that, in which case it should be out in a couple weeks, Asset Store approval included, but I can't assure I will (I hope the complicated period will be less complicated from next week) :B I'll let you know for next Wednesday.

    @monogon Many thanks to @fermmmm for the answer. And yes, I will totally add that to the website.

    @Mr_Cad Woah that is very weird, I was sure I replied you but can't find my answer. Anyway, I was saying that I checked the code (not on an Android but the overall logic) and that looks impossible, because as soon as Pause/Kill is called a boolean is set on the tween, which prevents it from being updated. Are you sure there is not a delay between the action that calls the pause and the pause itself, and you see it on Android because the framerate is lower?

    @fermmmm Can you try to raise the amount of tweens available via SetTweensCapacity and let me know if that happens again? I had a similar error report ages ago but I never managed to replicate it and thought I fixed that.

    @Afif Faris There is no way to get tweens by id right now, but it's a very interesting suggestion. Adding it to my todo list and will do it next week (or hopefully even this weekend).

    @s1m0n1stv4n Hi. You can use myTween.ChangeEndValue for that.

    @ratking Hiya, glad you like it! The reason there's no defaultTimeScaleIndependent is that, contrary to HOTween, you can now set independent timeScale even with Fixed and Late update tweens, so it's an additional option instead than just one of the update types. But you're right and I'll add a defaultTimeScaleIndependent option.

    @Rustamovich Hi!
    1) That is not a bad thing, but just a warning that you can set a higher capacity manually instead than let DOTween do it automatically, so the internal array that stores all tweens doesn't need to be updated when it overflows.
    2) I'm not sure what you mean. If you mean you want to keep your Sequence so it can be reused, then you have to prevent it from being killed automatically when it ends, by appending SetAutoKill(false) to the end of your Sequence chain. If I understood wrongly let me know.
    3) If you want to know if it's played completely, you can check if CompletedLoops is equal to the total number of loops you set. Though you made me realize that I should just add a way to check if it's fully complete. Will do that.
    If instead you want to check if it's been killed, you can check IsActive.

    @mimminito I suppose you're trying to play it backwards after it played fully forward? In that case, you have to prevent the Sequence to be auto-killed when it completes, by setting SetAutoKill(false).
    P.S. oh I realized you realized that already :D
     
  4. Afif-Faris

    Afif-Faris

    Joined:
    Oct 11, 2013
    Posts:
    16
    @Izitmee Wow, thanks. Its very useful feature. I just found out there's similiar feature in HOTween documentation.
    My current project is still prototype, so I will use HOTween for now until its implemented in DOTween.
    I like the DOTween sequencing, its more flexible that HOTween sequence. Great !!! :)
     
  5. Rustamovich

    Rustamovich

    Joined:
    Sep 5, 2014
    Posts:
    36
    @Izitmee thank you so much!
    Thank you for your answer so fast, Is it bad to create every time a new tween? the trouble is when I create tween in Start () - it created Vector 3 relatively to my position at start.
    Here is example:
    Code (CSharp):
    1.  MUpSeq.Append (transform.DOMove (new Vector3 (myPositionX, myPositionY + 1.5f, myPositionZ), 0.165f))
    So if object stay in vector3 (1,1,1) he moves to (1, 2.5, 1) for first play. If I reuse this tween - it moves to (1,1,1) back and perform animation move to (1,2.5,1)
    All I want is second sequence starts playing from place when first one ends.

    For example:
    Object in Vector3 (1,1,1)
    I perform:
    transform.DOMove(newVector3(1, 0,0), 1)); - as result object stays in 2,1,1
    I perform transform again:
    transform.DOMove(newVector3(1, 0,0), 1)); - as result I want to Object start do this move from 2.1.1 to 3.1.1

    How can I achieve this behavior?

    The main idea here is to restrict input while animation(sequence) is played, so you cant start new sequence til playing one plays,
    and I didnt use loops, sequence plays once.
     
    Last edited: Feb 20, 2015
  6. Revolter

    Revolter

    Joined:
    Mar 15, 2014
    Posts:
    216
    Is there a difference between tween.Kill(true); and tween.Complete(); if I set up the tweens to be recyclable?
     
  7. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    UPDATE 1.0.210
    Yey, BIIIIG update, with a lot of stuff and new features requested in previous posts plus some bugfix :)
    • NEW: Added WaitForRewind coroutine
    • NEW: Added myTween.fullPosition get/set property
    • NEW: Added DOVirtual.Float static method
    • NEW: Added DOVirtual.EasedValue static method
    • NEW: Regular callbacks like OnComplete now work with empty Sequences too
    • NEW: DOTween Utility Panel now has a Preferences Tab, which allows to set DOTween's default values
    • NEW: SafeMode is now implemented also for callbacks
    • NEW: Added DOTween.defaultTimeScaleIndependent static property
    • NEW: Added myTween.IsComplete() property
    • NEW: Added DOTween.TweensById and DOTween.TweensByTarget static property
    • BUGFIX: Added missing myTarget.DOComplete method
    • BUGFIX: Fixed tween duration not being calculated correctly with speed-based tweens in some cases
    • BUGFIX: Fixed tweens behaving incorrectly in some cases when FPS are extremely low
     
    Devil_Inside likes this.
  8. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    @Afif Faris: done :) It's called TweensById and not GetTweensById as you'll see. I also added a TweensByTarget while I was there.

    @ratking: defaultTimeScaleIndependent added!

    @Rustamovich DOTween is pretty fast, so it's no problem if you create a new tween each time. Still, if you're using a Tweener and not Sequences, you can store it and just change the start/end value.
    To restrict something while a tween is playing, you can just check myTween.IsPlaying().

    @Revolter: There is no difference independently of the recycling behaviour. A recyclable tween is still killed (and then recycled) when it completes, unless you set its autoKill behaviour to false.
     
  9. ratking

    ratking

    Joined:
    Feb 24, 2010
    Posts:
    349
    @Izitmee: Awesome! Thanks for the fast adding of a feature I requested! Will donate a bit.
     
  10. fermmmm

    fermmmm

    Joined:
    Oct 18, 2013
    Posts:
    129
    I could not make the error message reappear. So I can't test what you told me, I'm testing with a slow computer, framerate is good 150 fps, but the game runs with lag because the CPU is very weak and can't handle the game inside the Unity IDE very well, it lags in random moments but when a tween starts there is olways a delay, maybe that can help you to know what happened. Tell me if you want me to do something to try to replicate the error. I realy want my game to be stable and work with DoTween.
    Why don't you make a stress test with a slow CPU emulation, check this post:
    http://stackoverflow.com/questions/...n-a-simulated-low-memory-slow-cpu-environment
    and this one:
    http://stackoverflow.com/questions/...er-cpu-processor-machines-for-browser-testing
    My CPU is an AMD C-60 APU from an Aspire One small notebook.
    You can have 150fps and the game is still lagging. I came to the conclution that good FPS tells you more about the GPU than de CPU, lowering the framerate manually is not a slow PC simulation.
     
    Last edited: Feb 20, 2015
  11. s1m0n1stv4n

    s1m0n1stv4n

    Joined:
    Sep 14, 2012
    Posts:
    16
    @Izitmee Yes, I had the same idea, but I need to update the end value on every frame. So I tried .OnUpdate, and in the callback function I used .ChangeEndValue on the tween, but it totally freezes unity.

    I try to explain myself a bit better. I have object A and object B. Object A moves around the scene. What I'd like to achieve is creating a tween on B which makes B to move towards A until it reaches A, wherever A is.
    iTween has a method, iTween.MoveUpdate, which makes a continuous tween placed in Update(). I'd like to achieve something similar.

    Any ideas?
     
  12. Rustamovich

    Rustamovich

    Joined:
    Sep 5, 2014
    Posts:
    36
    Thank you, thats help me!

    But I think I have found a bug with transform.DORotate:
    If I perform
    transform.DORotate (new Vector3 (0 , 0, 180), 0.5f))
    objects moves exactly how it needed to move - so if in start I have 0.0.0 at the end I would have 0.0.180
    But if I perform:
    transform.DORotate (new Vector3 (180 , 0, 0), 0.5f))
    Object goes to 5.180.180
     
  13. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    @ratking Thank you very much! :)

    @fermmmm Will try to use those links for additional tests. Though that error has nothing to do with slow computers, but is eventually related to a bug I can't apparently reproduce, where in some very rare cases the max Tweener/Sequence capacity fails to increase automatically (that's why setting it manually solves it).

    @s1m0n1stv4n Indeed using ChangeEndValue inside an OnUpdate callback creates issue. I'll work around that, but in the meantime you could use a regular Unity Update call to change it.

    @Rustamovich What you see as the final result (in Unity's inspector) is a Vector3 conversion to Quaternions, which is often not the same as the original Vector3 value you passed, because Quaternions are more complicated than that. That said, your object did rotate only by 180° along the X axis, so it's all correct, but the Quaterion representation may look different.
     
  14. ratking

    ratking

    Joined:
    Feb 24, 2010
    Posts:
    349
    When I do your second line of code, I see "-5.008956e-06" as value for the X rotation, which basically is the same as 0. And yes, eulerAngles == 0/180/180 is the same as eulerAngles == 180/0/0
     
    Demigiant likes this.
  15. Mr_Cad

    Mr_Cad

    Joined:
    Dec 7, 2013
    Posts:
    27
    I found it weird too because it is working fine on Editor. I'm actually running it on iPhone 5. I've recorded a short clip and I would like to show you. Is there any email address where I can send it to you so u can take a look?
     
  16. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    @Mr_Cad Sure. Write me a private message as a starter, and I'll check it out and write you my mail (or you can write me directly via the mail form on this page).
     
  17. fermmmm

    fermmmm

    Joined:
    Oct 18, 2013
    Posts:
    129
    @Izitmee Maximum tweens is something related with recycling? I don't have recycling enabled.
     
  18. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    @fermmmm Nono, it's just the max size of the array that stores the tweens, and is used both with and without reycling.
     
  19. s1m0n1stv4n

    s1m0n1stv4n

    Joined:
    Sep 14, 2012
    Posts:
    16
    Thank you very much!
     
  20. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    UPDATE 1.0.220
    • CHANGE: Added PathMode.Ignore, which will ignore any LookAt option you might pass
    • BUGFIX: Fixed closed paths creating an additional point at 0,0,0 in case the first waypoint and the Transform's position coincided

    @zombiegorilla This fixes your closed paths issue. Took me a while because I couldn't reproduce it, until I realized that happened only if the first waypoint and the initial transform's position coincided (thanks to @Baroni for pointing that out).
     
  21. TheValar

    TheValar

    Joined:
    Nov 12, 2012
    Posts:
    760
    Hey @Izitmee just started uisng DOTween this weekend and am inlove. I do have one (probably dumb) question though. Is there a way to apply different transform tweens simultaneously? For example doing a transform.DOShakePosition and DOShakeRotation at the same time. It seems like if I call one after the other one of them gets cancelled.

    EDIT: nvmd, I'm pretty sure this is accomplished with sequence.insert
     
    Last edited: Feb 23, 2015
  22. Ox_

    Ox_

    Joined:
    Jun 9, 2013
    Posts:
    93
    Hi!

    I'm passing an Action into my method that contains a DOTween and DOTween refuses to use it for OnComlete:
    Code (CSharp):
    1. void ShowScoreText(ExtTextMesh text, Action callback)
    2. {
    3.     DOTween.ToAlpha(
    4.         () => text.gameObject.renderer.material.color,
    5.         val => text.gameObject.renderer.material.color = val,
    6.         1f, scoreNamesAppearanceDuration).OnComplete(callback);
    7. }
    Argument `#2' cannot convert `System.Action' expression to type `DG.Tweening.Core.TweenCallback'

    What am I missing?

    Thanks!
     
  23. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    @TheValar Hiya! Glad you're liking it :) You cannot apply different position tweens at the same time (because the last one will overwrite the others), but:
    • you can apply a DOMoveX, a DOMoveY and a DOMoveX at the same time
    • you can apply a position tween and a rotation tween at the same time
    • I just tested it, and DOShakePosition and DOShakeRotation do work at the same time (as they should). If you're sure this isn't happening, can you reproduce it in a barebone project and attach it here so I can check it out?
    @Ox_ Hi! I actually don't use Actions but TweenCallback types. They are the exact equivalent of Actions but coded in a custom way, simply because some older Unity version doesn't support Action types on some platforms (specifically Action<T>). The attached update moves the TweenCallback type to the regular DG.Tweening namespace, so you can use that type easily instead of an Action.
    Code (csharp):
    1. void ShowScoreText(ExtTextMesh text, TweenCallback callback)
    2. {
    3.     DOTween.ToAlpha(
    4.     () => text.gameObject.renderer.material.color,
    5.     val => text.gameObject.renderer.material.color = val,
    6.     1f, scoreNamesAppearanceDuration).OnComplete(callback);
    7. }
     

    Attached Files:

    TheValar likes this.
  24. Afif-Faris

    Afif-Faris

    Joined:
    Oct 11, 2013
    Posts:
    16
    Thank you for adding the new feature so fast!! Kudos!!
     
  25. Rustamovich

    Rustamovich

    Joined:
    Sep 5, 2014
    Posts:
    36
    Can you explain me how to animate object in way when it moves only by X axis
    Thanks in Advance!
     
  26. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    @Rustamovich If by move you mean rotate, what you did is correct and there is no other way. Your object rotated only on the X axis, but you can't expect Quaternions to reflect that because they use a different system. You can see it yourself if you try to rotate an object directly with the rotation handles in the Scene view: rotate it by 180* then release it, and you'll see Unity's Inspector showing something else than 180,0,0.
     
    Last edited: Feb 25, 2015
  27. SidarVasco

    SidarVasco

    Joined:
    Feb 9, 2015
    Posts:
    163
    I'm trying to use DoTween.To in a forloop ( not foreach ) but only one item is tweened. Any tips?

    Code (csharp):
    1.  
    2.   RectTransform r;
    3.         for (int i = current+1; i < list.Count; i++) {
    4.            
    5.             r = list[i].Container.GetComponent<RectTransform>();
    6.  
    7.              DOTween.To(
    8.                 () => r.localPosition,
    9.                 pos => r.localPosition = pos,
    10.                 r.localPosition + new Vector3(0, VerticalOffset, 0),
    11.                 0.5f
    12.             );
    13.         }
    14.  
     
    Last edited: Feb 25, 2015
  28. Revolter

    Revolter

    Joined:
    Mar 15, 2014
    Posts:
    216
    1) Regarding Safe Mode, is it to avoid null references if the gameobject is destroyed?
    2) Does it affect the working of tweens if an object is disabled instead?
    3) Does a tween stop if I disable the gameobject or do I have to stop it manually?
     
  29. fermmmm

    fermmmm

    Joined:
    Oct 18, 2013
    Posts:
    129
    Don't create "r" outside the for loop because will be reasigned all the time, lambdas keep reading "r" after the loop is finished and until the tween finishes, if "r" was reasigned your tweens will not work as expected.
    You need a new "r" in every for iteration for every tween like this:

    Code (csharp):
    1.  
    2.         for (int i = current+1; i < list.Count; i++) {
    3.    
    4.             RectTransform r = list[i].Container.GetComponent<RectTransform>();
    5.  
    6.              DOTween.To(
    7.                 () => r.localPosition,
    8.                 pos => r.localPosition = pos,
    9.                 r.localPosition + new Vector3(0, VerticalOffset, 0),
    10.                 0.5f
    11.             );
    12.         }
    13.  
     
    Last edited: Feb 26, 2015
  30. fermmmm

    fermmmm

    Joined:
    Oct 18, 2013
    Posts:
    129
    Again:

    Code (CSharp):
    1. IndexOutOfRangeException: Array index is out of range.
    2. (wrapper stelemref) object:stelemref (object,intptr,object)
    3. DG.Tweening.Core.TweenManager.AddActiveTween (DG.Tweening.Tween t) (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__DOTween.Assembly/DOTween/Core/TweenManager.cs:715)
    4. DG.Tweening.Core.TweenManager.GetTweener[Single,Single,FloatOptions] () (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__DOTween.Assembly/DOTween/Core/TweenManager.cs:95)
    5. DG.Tweening.DOTween.ApplyTo[Single,Single,FloatOptions] (DG.Tweening.Core.DOGetter`1 getter, DG.Tweening.Core.DOSetter`1 setter, Single endValue, Single duration, DG.Tweening.Plugins.Core.ABSTweenPlugin`3 plugin) (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__DOTween.Assembly/DOTween/DOTween.cs:841)
    6. DG.Tweening.DOTween.To (DG.Tweening.Core.DOGetter`1 getter, DG.Tweening.Core.DOSetter`1 setter, Single endValue, Single duration) (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__DOTween.Assembly/DOTween/DOTween.cs:263)
    7. DelayedCall..ctor (Single milisecondsToCall, DG.Tweening.Core.TweenCallback action, Int32 repeatTimes, Boolean timeScaleIndependent) (at Assets/Imported Packages/fermmmScripts/FastCoding/DelayedCall.cs:18)
    8. GameController.Start () (at Assets/Scripts/Core/GameController.cs:42)
    9.  
    Happened right after DoTween.KillAll() was called, I think that when it happens is olways after that call.
    I'm sorry to say this but DoTween is crashing my game in random moments with that error, It's not usable for me.
    Also there are tweens that never get completed in random moments when playing the game in the windows build (not in the editor), I didn't tell you that one because I don't know how to reproduce the issue eather.
    I think DoTween should still be a in alpha or beta and you should make more testing, I'm moving to leantween or dftween until DoTween gets more stable.
     
    Last edited: Feb 26, 2015
  31. ortin

    ortin

    Joined:
    Jan 13, 2013
    Posts:
    221
    Is there any equivalent of TweenMax.delayedCall(time, action) in DOTween? So I just need to call some action with delay and making/starting coroutine is a clumsy way to do it as for me.
     
  32. Revolter

    Revolter

    Joined:
    Mar 15, 2014
    Posts:
    216
    Did you try DoTween.KillAll(false)? KillAll completes the tweens by default.

    Also (this might explain why some of your tweens don't complete):
    recycleAllByDefault If TRUE all new tweens will be set for recycling, meaning that when killed they won't be destroyed but instead will be put in a pool and reused rather than creating new tweens. This option allows you to avoid GC allocations by reusing tweens, but you will have to take care of tween references, since they might result active even if they were killed (since they might have been respawned and might now be in use as other completely different tweens).
     
    Last edited: Feb 26, 2015
  33. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    UPDATE v1.0.250

    @ortin I wanted to add it since a while, so now I did it :)

    @Revolter 1) Exactly for that. And also to avoid errors in case your OnComplete/OnEtc callback contains bad code (usually because it was referring to something that got destroyed)
    2 + 3) Nothing to do with disabled objects. If an object is disabled or enabled the tween won't care at all and will continue to run without errors (until the object is destroyed, in which case welcome back safe mode). The values of said objects will be changed accordingly, even if they won't be visible in case they're related to visuals.
     
  34. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    @fermmmm Nothing, I tried more tests with KillAll but I can't reproduce your error (though for the non-completing tweens it's probably what @Revolter said). There must be something weird, considering you're the only user getting it. Did you try increasing the capacity so it's no increased automatically, as I suggested? Also, if you still have some time, let me know what else you call after KillAll, since that method can't generate that error, so I suppose you're immediately creating new tweens after that?
     
  35. Devil_Inside

    Devil_Inside

    Joined:
    Nov 19, 2012
    Posts:
    1,117
    I couldn't reproduce it myself, but I've got a few reports through analytics for a similar exception. Compared to other errors I get through analytics, this one is pretty rare.
    Code (CSharp):
    1. IndexOutOfRangeException: Array index is out of range.
    2. (wrapper stelemref) object:stelemref (object,intptr,object)
    3. DG.Tweening.Core.TweenManager.ReorganizeActiveTweens ()
    4. DG.Tweening.Core.TweenManager.Update (UpdateType updateType, Single deltaTime, Single independentTime)
    5. DG.Tweening.Core.DOTweenComponent.Update ()
     
  36. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    Damn, thanks for the report @Devil_Inside. Ok I'll try to spend as much time as I can within the weekend to try and replicate this. I'm pretty baffled. Can you paste a screenshot of your DOTween Utility Panel preferences in the meantime, so I can use the same as yours?
     
  37. Revolter

    Revolter

    Joined:
    Mar 15, 2014
    Posts:
    216
    @Izitmee, would it be possible to add a global setting for the tween to get killed when the GameObject becomes inactive?
     
  38. SidarVasco

    SidarVasco

    Joined:
    Feb 9, 2015
    Posts:
    163
    Thanks. I thought that was only a problem with foreach loops. Learned something new.
     
  39. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    @Revolter I would prefer not, because it would add at least an "if" even for tweens that wouldn't need that (and I prefer to keep things as fast as possible). That said, you could easily add that when you need it, like this:
    Code (csharp):
    1. Tween myTween = myTransform.DOMoveX(2, 1).OnUpdate(()=> {
    2.    if (!myGameObject.enabled) myTween.Kill();
    3. });
    :)
     
  40. Revolter

    Revolter

    Joined:
    Mar 15, 2014
    Posts:
    216
    Got it. I was thinking to go a different route:
    Code (csharp):
    1. void OnDisable()
    2. {
    3.     if(myTween!=null)
    4.         myTween.Kill();
    5. }
     
    Last edited: Feb 26, 2015
  41. Devil_Inside

    Devil_Inside

    Joined:
    Nov 19, 2012
    Posts:
    1,117
    Sorry, I don't know if the game version that is reporting the errors is the one that uses the updated DOTween with Utility Panel. It might very well be someone using an older version as, unfortunately, I don't have the exact version in the crash report.
    Overall this error doesn't really bother me, as it's very rare. Also, seeing how I can't reproduce it myself, @fermmmm could be of better help in this case.
     
  42. mfosati

    mfosati

    Joined:
    Apr 24, 2014
    Posts:
    13
    Weird error. My Windows Phone 8.1 game was working just fine when I was building from visual studios. I uploaded for certification and then downloaded from the store. Now, none of the tween is working. The game works fine on the Windows Store and the Surface RT. Any ideas?
     
  43. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    @Revolter That would work perfectly too! Also, since Kill uses an extension method, DOTween has a safe-system when calling myTween.Kill. So you don't need to check if myTween is null. If it is, nothing will happen.

    @mfosati That is very weird and kind of disturbing. I would suggest to send your project to Unity, since that definitely sounds like a Unity bug. In the meantime, where are you creating the tweens? It seems much more probable that something is happening somewhere and the lines of code that are creating them are not being called? Do you have a way to check logs from the store version?
     
  44. FuguFirecracker

    FuguFirecracker

    Joined:
    Sep 20, 2011
    Posts:
    419
    @Izitmee
    Thank you so much for DOTween. When the 'Pro' version is released, I'll buy it.

    Having the one hiccup, though...

    On Android and Windows Phone
    The first tween after my project loads on the device always skips or stutters. Subsequent tweens,however, are smooth and fluid.

    So I'm thinking I should do some background chicanery on invisible gameobjects... get that first malfunctioning tween out of the way out of sight.

    But that seems like a rather inelegant and wasteful resort.

    So... How do I overcome the initial skip?
    Anyway to prewarm a tween? Or maybe call the tween but delay execution?

    No issues on desktop.
     
  45. ilovemypixels

    ilovemypixels

    Joined:
    Oct 16, 2012
    Posts:
    6
    Hi there,

    I'm having a lot of trouble with DOTween at the moment, and I'm starting to wonder if something has corrupted or not been imported correctly. My project stopped working the way it was supposed to. I am not getting any actual major (red) error but I am getting errors inside DOTween.


    DOTWEEN :: DOTween auto-initialized with default settings (recycleAllByDefault: False, useSafeMode: True, logBehaviour: ErrorsOnly). Call DOTween.Init before creating your first tween in order to choose the settings yourself
    UnityEngine.Debug:LogWarning(Object)
    DG.Tweening.Core.Debugger:LogWarning(Object) (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__DOTween.Assembly/DOTween/Core/Debugger.cs:22)
    DG.Tweening.DOTween:InitCheck() (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__DOTween.Assembly/DOTween/DOTween.cs:776)
    DG.Tweening.DOTween:ApplyTo(DOGetter`1, DOSetter`1, Vector3, Single, ABSTweenPlugin`3) (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__DOTween.Assembly/DOTween/DOTween.cs:784)
    DG.Tweening.DOTween:To(DOGetter`1, DOSetter`1, Vector3, Single) (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__DOTween.Assembly/DOTween/DOTween.cs:268)
    DG.Tweening.ShortcutExtensions:DOMoveX(Transform, Single, Single, Boolean) (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__DOTween.Assembly/DOTween/ShortcutExtensions.cs:318)
    ChangeObject:nextObject(String) (at Assets/Scripts/ChangeObject.cs:113)
    ChangeObject:navArrowPressed(String) (at Assets/Scripts/ChangeObject.cs:239)
    UnityEngine.EventSystems.EventSystem:Update()

    I have got to this list after commenting out many of my tweens. The tweens in question that are being logged look like this.

    oldObject.transform.DOMoveX(objectOffset, mainScript.mainSwipeFadeSpeed).SetEase(Ease.InQuad).OnComplete(hideOld);

    but many of the ones I had to comment out look more innocent like this

    frontBgPlane.renderer.material.DOFade(0f, mainScript.mainSwipeFadeSpeed).OnComplete(doSwitch);

    I seem to always have to declare the renderer.material explicitly every time, i'm not sure if this is normal.

    Thanks for any help you can give
     
  46. kalovito66

    kalovito66

    Joined:
    Oct 19, 2014
    Posts:
    2
    Thank you for the new DOTween updates.

    Am have been trying to shift from HOTween to DOTween on all my projects but i get stuck on how to use the "prop" variable that comes with HOTween.

    How do i change the following code to use DOTween;

    Code (CSharp):
    1. for (int x = 0; x <= gridW; x++)
    2.             {
    3.                 for (int y = 0; y <= gridH; y++)
    4.                 {
    5.  
    6.                     var parms = new TweenParms().Prop("position", new Vector3(x, y, -1)).Ease(EaseType.EaseOutQuint);
    7.                     HOTween.To(cells[x, y].transform, .4f, parms);
    8.                 }
    9.             }
    Looking forward to your advice. Thanks
     
  47. Gaspar

    Gaspar

    Joined:
    Jun 14, 2014
    Posts:
    28
    I have problems on Windows Phone 8.1 too. Problem reproduces only on Windows Phone, only on devices(ok in simulator) and only in Release mode.
    After little research i can say that issue in PluginManager of DOTween. GetDefault plugin returns null for classes like Vector3 or Color. So all tween based on this plugins throws nullreference exception.

    A way to reproduce:
    Code (CSharp):
    1. using DG.Tweening;
    2. using UnityEngine;
    3.  
    4. public class Controller : MonoBehaviour
    5. {
    6.     public GameObject obj;
    7.  
    8.     public void Start()
    9.     {
    10.         Debug.Log("DOTween TEST");
    11.         obj.transform.DOMove(Vector3.zero, 1f);
    12.     }
    13. }
    14.  
    Next steps:
    1) Build Windows Store, SDK = Phone 8.1
    2) Select Release and Devices in Visual Studio
    3) Run on Device

    Log(Garbage deleted):
    Code (CSharp):
    1. ...
    2. Module information:
    3. Built with Compiler Ver '180030324'
    4. Built from 'release/4.6/release' branch
    5. Version is '4.6.2f1 (bd99309c2ad7)'
    6. Release build
    7. Application type 'XAML'
    8. Used 'PhoneSDK 8.1'
    9. ...
    10.  
    11. DOTween TEST
    12.  
    13. DOTWEEN :: No suitable plugin found for this type
    14.  
    15. Exception: Object reference not set to an instance of an object.
    16. Type: System.NullReferenceException
    17. Module: DOTween
    18. InnerException: <No Data>
    19. AdditionalInfo:<No Data>
    20.    at DG.Tweening.ShortcutExtensions.DOMove(Transform target, Vector3 endValue, Single duration, Boolean snapping)
    21.    at Controller.Start()
    22.    at Controller.$Invoke0(Int64 instance, Int64* args)
    23.    at UnityEngine.Internal.$MethodUtility.InvokeMethod(Int64 instance, Int64* args, IntPtr method)
    24.  
    25. NullReferenceException: Object reference not set to an instance of an object.
    26.    at DG.Tweening.ShortcutExtensions.DOMove(Transform target, Vector3 endValue, Single duration, Boolean snapping)
    27.    at Controller.Start()
    28.    at Controller.$Invoke0(Int64 instance, Int64* args)
    29.    at UnityEngine.Internal.$MethodUtility.InvokeMethod(Int64 instance, Int64* args, IntPtr method)
    Debugger:
    http://prntscr.com/6auwhj
    http://prntscr.com/6auwqi
     
  48. Gaga_Notion

    Gaga_Notion

    Joined:
    Jul 26, 2014
    Posts:
    1
    Hello. I want to make a smooth movement for player. When I use transform.Translate my character moves immediately, but he react at local coordinates. When I use DOLocalMove i get smooth, but he always move in one direction and don't react at the local rotation coordinates. What I need to do to solve this problem?

    if(Input.GetKeyDown(KeyCode.UpArrow)){
    transform.DOLocalMove(Vector3.right * moveSpeed, 1, false).SetRelative(true);
    }

    if(Input.GetKeyDown(KeyCode.DownArrow)){
    transform.Translate(-Vector3.right * moveSpeed);
    }​
     
  49. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    @FuguFirecracker That hiccup is usually due to that fact that Unity is, let's say, initializing the idea that stuff might move (especially when it involves the new Unity UI), more than to tweens. To be sure DOTween is as ready as it can though, you should call DOTween.Init as soon as possible (to avoid it being called the first time a tween is created). If you call it like this:
    Code (csharp):
    1. DOTween.Init();
    it will initialize with the preferences you set in DOTween's Utility Panel.
    Also, if while playing you get a warning that the tweens capacities were auto-incremented (in case you're using hundreds of tweens), you could set them immediately at some high size while calling Init:
    Code (csharp):
    1. DOTween.Init().SetCapacity(1000, 1000);
    @ilovemypixels Don't worry, that is not an error but a useful warning. It's telling you that you can call DOTween.Init yourself to initialize things manually, instead than having it called automatically when the first tween is created.

    @kalovito66 Hiya! This HOTween code:
    Code (csharp):
    1. for (int x = 0; x <= gridW; x++)
    2. {
    3.    for (int y = 0; y <= gridH; y++)
    4.    {
    5.       var parms = new TweenParms().Prop("position", new Vector3(x, y, -1)).Ease(EaseType.EaseOutQuint);
    6.       HOTween.To(cells[x, y].transform, .4f, parms);
    7.    }
    8. }
    Becomes this in DOTween:
    Code (csharp):
    1. for (int x = 0; x <= gridW; x++)
    2. {
    3.    for (int y = 0; y <= gridH; y++)
    4.    {
    5.       cells[x, y].DOMove(new Vector3(x, y, -1), .4f).SetEase(Ease.OutQuint);
    6.    }
    7. }
    In short, TweenParms still exist (they're now called TweenParams, and work slightly differently) but they're not necessary at all. They're there just an additional option.

    @Gaspar That is very disturbing :O Thanks for the research. It seems like some weird Unity bug somehow, because GetDefaultPlugin is a very simple method. Also, from your screenshots I see that the vector3plugin is actually created, but then somehow lost when passed as a reference. Could I ask you to send your project to Unity as a bug report? Also, if you have time, these things would help me in trying to fix this in the meantime (I don't have a Windows 8 device to test it personally):
    1. Does tweening a non-Unity object (like a float) work, or that doesn't either?
    2. Could you take two more screenshots, with the same contents you showed me, but expanded so I can fully see what is written in the Type column?
    3. Could you try to build your example with the DOTween version I'm attaching here (1.0.251), and post screenshots again? It adds a line of code before row 71 of your second screenshot (inside Tweener), to check if the problem is GetDefaultPlugin returning a NULL value, or t.tweenPlugin somehow not storing it
    @Gaga_Notion If you want to move your Transform based on its current direction, you could either place it inside a container and: use the container for rotations, use the child for movement. Otherwise you could apply your target's rotation to the end value like this:
    Code (csharp):
    1. transform.DOLocalMove(transform.localRotation * Vector3.right * moveSpeed, 1, false).SetRelative(true);
     

    Attached Files:

  50. Gaspar

    Gaspar

    Joined:
    Jun 14, 2014
    Posts:
    28
    Now it looks like Visual Studio 2013 bug, not Unity bug.
    http://prntscr.com/6bcqsh
    I have "Tween 2" in Log with this code.
    (Tried with DOTween 250, Visual Studio 2013 Update 4 and Visual Studio 2013 Update 5 CTP)

    Then i have exception:

    Exception: Unable to cast object of type 'DG.Tweening.Plugins.Vector3Plugin' to type 'DG.Tweening.Plugins.Core.ABSTweenPlugin`3[UnityEngine.Vector3,UnityEngine.Vector3,DG.Tweening.Plugins.Options.VectorOptions]'.
    Type: System.InvalidCastException
    Module: Assembly-CSharp
    InnerException: <No Data>
    AdditionalInfo:<No Data>
    at Controller.Start()
    at Controller.$Invoke0(Int64 instance, Int64* args)
    at UnityEngine.Internal.$MethodUtility.InvokeMethod(Int64 instance, Int64* args, IntPtr method)
     
    Last edited: Mar 1, 2015