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. Devil_Inside

    Devil_Inside

    Joined:
    Nov 19, 2012
    Posts:
    1,117
    Just got to try the PRO features and I really like how DOTweenAnimation component works! Just what I needed for a section of my game!
    However I'm a bit confused about the Visual Manager.
    I have 2 DOTween animation components on a single object and they work as a sequence on the same property (the second component has AutoPlay turned off, and I run a DOTweenAnimation.DOPlayNext as OnComplete event of the first animation).
    Now I want the sequence to stop when the object is disabled, and to restart when the object is enabled.
    I've tried using the Visual Manager, but it seems to restart both tween animations separately, and I don't see a way to make it restart those animations as a sequence. Maybe there should be a RestartNext option or something?
    Also, I couldn't find what "Restart From Spawn Point" could mean?
    Thank you!
     
  2. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    Hey @Devil_Inside! Glad you like it :)

    The thing is, DOTweenAnimations are not really a Sequence, just two separate tweens (I'm actually planning to add a new DOTweenSequence component to truly create a Sequence that can be managed like that) so when you call Restart from the VisualManager, all tweens are restarted indeed.
    If you want to play them as a Sequence, and have Restart work, scrap that OnComplete and DOPlayNext. Instead, set a delay to the second tween (and reactivate AutoPlay), so that it's as long as the first tween's duration. That way, when they both Restart, they will still behave as a fake-sequence.

    About RestartFromSpawnPoint, that's a utility function when using tweens on objects that are randomly spawned. Rather than just restarting, it also re-adapts the start and end positions (or the waypoints in case of a path) based on the new position of the target—only if the tween was set to relative.

    Cheers!
     
  3. badawe

    badawe

    Joined:
    Jan 17, 2011
    Posts:
    297
    The problem for me, is that is not an option in Unity Cloud :(

    And a re import did not solve the problem :(
     
  4. Devil_Inside

    Devil_Inside

    Joined:
    Nov 19, 2012
    Posts:
    1,117
    Thanks for a quick reply.
    I've tried what you suggested with the delay, but there's a noticeable jump the moment the second animation kicks in. I think it has something to do with both tweens being initialized from the same initial position, and thus while the first tween moves the object away, when the second tween starts after a delay, the object jumps to that initial position and continues to tween from there, rather than tweening from end position of the first tween.
     
  5. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    @badawe Oh wait! I hadn't seen the Finder screenshot when I replied, and now I realize that there are indeed missing files (sorry I was tricked by the extension-less representation in the Project panel: "DOTween.dll" is actually "DOTween.dll.mdb"). The actual libraries are missing. There is no DOTween.dll, DOTween43.dll etc, only the XML and MDB files (which end with "dll.mdb"), which are used only for intellisense and error logging. That is very weird. Can you check that you actually have the dll files in your repo? I don't see any possible reason why they wouldn't be checked out correctly if they're there.

    @Devil_Inside If you're tweening the same property of the same target, then yes, since they're not created as Sequences both start and end values will be stored at startup. Can you tell me more of what type of animation you're trying to achieve? Maybe I can find a solution in the meantime.
     
  6. badawe

    badawe

    Joined:
    Jan 17, 2011
    Posts:
    297
    Turns out, after a long search about it, source three ignore .dll files in the global ignore :(

    After remove that, everything works fine.
     
    meapps likes this.
  7. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    Whew, glad we found the mystery :)
     
  8. Devil_Inside

    Devil_Inside

    Joined:
    Nov 19, 2012
    Posts:
    1,117
    I'm doing some kind of weapon showcase, where a new weapon first rotates into position, and from that position it starts an infinite yoyo loop to display it from different angles.
     
  9. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    That is a pretty complex animation. What about the setup I'm attaching (requires Unity 5, and doesn't contain DOTween Pro)?

    SwordShowcase.gif
     

    Attached Files:

  10. BTStone

    BTStone

    Joined:
    Mar 10, 2012
    Posts:
    1,422
    Hey Daniele,

    what would be the best way to LocalMove AND Shake/Position an Object via the DOTweenAnimation Component?

    I have a Bush-Sprite (2DTK) and want it to move in the X-Axis by a certain value and while it moves I want it to shake a little.

    I attached a little Screenshot how my setup looks right now:

    Inspector.jpg

    I'm playing the LocalMove-Animation via ID ("Stag") which calls the ShakePosition-Animation in each OnUpdate-Event.

    If I don't call the ShakePosition-Animation at all, it does move without problems. I guess ShakePosition and altering the Position in any other way don't work together that great. Any workaround?
     
  11. Devil_Inside

    Devil_Inside

    Joined:
    Nov 19, 2012
    Posts:
    1,117
    @Izitmee Heh, that's a great example :) I like the art :)
    You didn't use Visual Manager, which I was trying to use, but you gave me an idea with those separate components on parent and child. It should work fine with the visual manager in my case, so thanks a lot for your time!!!

    @BTStone Parent and child combo is probably the easiest thing to do in your case as well. You put the move on the parent, and the shake on the child.
     
    BTStone likes this.
  12. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    @Devil_Inside Woops, forgot about the Visual Manager :B Glad you still found it useful :)

    @BTStone Devil's suggestion is definitely the right way to go. Both Shake and Move act on the same property (which is position, because a transform's localPosition is just a recalculated position), so they would overwrite each other if acting also on the same target.
     
    BTStone likes this.
  13. timothyallan

    timothyallan

    Joined:
    May 22, 2013
    Posts:
    72
    Sooo, kill has a "complete" bool... could pause also have a "complete" bool as well, or am I overlooking something that's there already?

    I'm doing a hover animation where I want to start the animation on mouse over, and pause onmouseout, but I want the animation to always go back to the start position of the sequence on mouse out. I could kill the sequence and recreate the sequence every time, but I'd rather just create the sequence on start once and re-use it.
     
  14. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    @timothyallan Wait, you practically want a "pause and rewind", not a "pause and complete", right? Because if so, you can simply call myTween.Rewind(), and that will both rewind and pause it :)
     
    meapps likes this.
  15. BTStone

    BTStone

    Joined:
    Mar 10, 2012
    Posts:
    1,422
    Yep that did the job!

    Another one: I wanted to fade a 2DTK-Sprite via the Animation Component, but I get this error:

    For the record: I'm using the basic tk2d/BlendVertexColor Shader
     
  16. timothyallan

    timothyallan

    Joined:
    May 22, 2013
    Posts:
    72
    The issue with rewind is that it jump back to "frame 1" so to speak. I want the sequence to finish smoothly, and then rewind. So I guess it would be more of a "Complete then pause" functionality, much like the Kill "complete" flag... except without all the killing :)

    Edit:
    This would be trivial if I knew the number of loops I wanted, except this has to be an infinite loop as I don't know how long the user will hover over the item.

    Think of an inventory screen where hovering over an item causes it to pulse the object scale a bit from 1-2. Moving the mouse off would ideally complete the pulse, which started at localscale 1. Rewinding it on mouseout could leave the localscale at 1.3 for example.
     
  17. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    @BTStone It seems like you didn't import correctly DOTween Pro, and thus don't have the additional 2D Toolkit methods (so DOTweenAnimation tries to use a regular Material Fade on a tk2dSprite, which will fail). If you imported 2D Toolkit after running DOTween Setup, reimport DOTween Pro and re-run the setup.

    @timothyallan I am getting confused here :D If you let the tween play forward, it will complete automatically and then pause itself as you want. And if you want to reuse it, you just have to add a SetAutoKill(false), so that the tween will simply pause after completion but will not also be killed. Am I missing something?
     
    BTStone likes this.
  18. timothyallan

    timothyallan

    Joined:
    May 22, 2013
    Posts:
    72
    Ha, you were typing as I was doing my update above explaining the situation more... scroll up a post :)
     
  19. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    @timothyallan Ah! I see now! That is a little more complicated, because infinite loops can't complete. But there's a trick you could use. Let me wrap up an example and I'll be back ;)
     
  20. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    @timothyallan Example made. But I thought, why not, let me add a SmoothRewind method. Working on it right now.
     
  21. timothyallan

    timothyallan

    Joined:
    May 22, 2013
    Posts:
    72
    The only smooth thing around here is you! Nice one :)
     
  22. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    Ehehe, voilà :) Grab this update, then just call
    Code (csharp):
    1. myTween.SmoothRewind();
    inside your mouseExit method, and you're done.
     

    Attached Files:

  23. timothyallan

    timothyallan

    Joined:
    May 22, 2013
    Posts:
    72
    Awesome, I'll give it a shot ASAP. Will this play nicely with my latest Pro version?
     
  24. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
  25. neonblitzer

    neonblitzer

    Joined:
    Aug 5, 2013
    Posts:
    13
    Hiya! I just noticed that DOTween Pro's special license says that you need only one license per company, yet on Asset Store it's in the Editor Extensions category, which requires one license per seat. Did I misunderstand something?
     
  26. Pinsukka

    Pinsukka

    Joined:
    Feb 17, 2014
    Posts:
    15
    Hello again Izitmee, I noticed another little problem with DOTween Pro paths. When I have something that starts following a path from right to left, the mesh flips around (again, haha...). Everything works fine when the mesh goes from left to right though, strange! Here is an image to demonstrate the problem:

    https://drive.google.com/file/d/0BwqoHs0fUEMXMVR2UHMycmVpSUE/view?usp=sharing

    I think I had this problem earlier already, but forgot about the whole thing because of the disable/enable flip bug.

    Any idea how to fix this? :)
     
    Last edited: Jun 5, 2015
  27. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    @neonblitzer Ahoy! Damn I forgot to change the website's license, since Unity's Asset Store is the one that has priority. I changed it now, and if you already got DOTween Pro contact me so we can talk about it.

    @Pinsukka Hello! Oops you're right, but that would need your intervention to be solved. DOTween finds the shortest rotation to orient to a path, and if at startup the ship is oriented towards the Z, when going immediately left the shortest rotation is indeed achieved by flipping the ship's cockpit. You should orient the ship before the tween starts, so that when the tween plays it deduces the correct one and goes on from there. See this pic here :)

    dotween_orientation.png

    On a side note, I believe I already asked you but I don't remember: are you by any chance moving your ship only on the Y/X axes? Or you need the Z one too?
     
  28. MrEsquire

    MrEsquire

    Joined:
    Nov 5, 2013
    Posts:
    2,712
    Seems in the latest free build the behavior of "DOFade" has changed or somehow broken.
    Updating DOTween on existing projects, breaks Fade functionality (Unity4.6.5)
    Can we check this? or something has changed, apologies not read whole thread.
     
  29. Pinsukka

    Pinsukka

    Joined:
    Feb 17, 2014
    Posts:
    15
    @Izitmee I see... Well, this is not a big deal, I can just flip the models in advance if I need to. I only need Y/X axes for movement, the game uses orthographic camera.
     
  30. meapps

    meapps

    Joined:
    May 21, 2013
    Posts:
    167
    @Izitmee I would love to give some Scoreeffect examples how I did it away. Could you add it to the Examples from DoTween ?
     
  31. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    @MrEsquire I just checked to be sure, and DOFade works as usual. Did you run the DOTween Utility Panel Setup again after upgrading? Maybe you're missing the additional libraries that it adds.

    @Pinsukka If you need only Y/X axes I might have a solution which won't require flipping, but I'll have to implement it. I'll be out until Sunday, but then I'll work on it.

    @meapps You mean you'd like to share an example package? Sure, attach it here so I can check it out (it's DOTween standard, no Pro included, right?) :)
     
  32. meapps

    meapps

    Joined:
    May 21, 2013
    Posts:
    167
    @Izitmee yes i want to share some example i think it could help for some to get started and also could promote your plugin more...
     
  33. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    That would be great, thanks for sharing :) Attach it here and I'll check it out and then upload it to the website (though I might not be able to do that before Sunday, because I'll be out all day tomorrow).
     
    meapps likes this.
  34. meapps

    meapps

    Joined:
    May 21, 2013
    Posts:
    167
    @Izitmee sure, i just need to finish some updates for my games.
     
  35. MrEsquire

    MrEsquire

    Joined:
    Nov 5, 2013
    Posts:
    2,712
    My apologies you are correct, I figured out the issue, on upgrade of DoTween, I usually delete the whole folder and replace with new version. But of course forgot to check my DoTween settings. I had unticked "TimeScale Independent" hence the weird behavior I was having with the Fade, should be ticked.

    Whats the best way to upgrade versions in the future without loosing the settings?
     
  36. exitsimulation

    exitsimulation

    Joined:
    Feb 10, 2014
    Posts:
    82
    @Izitmee
    I am having problems setting the duration of a DoTweenPath Component from script. Basically I have to sync the path-tween's length to a timeline from another asset. Therefore I am setting doTweenPath.duration from script before playing the path tween. Is it supposed to work this way? Because right now I can only change the duration of a path tween before entering play mode.
    (The path tween is NOT set to autoplay)

    Edit: Fixed it with the right execution order!
     
    Last edited: Jun 8, 2015
  37. bigcatsobig

    bigcatsobig

    Joined:
    Dec 9, 2014
    Posts:
    9
    i have some problem setting recycle tween.

    i'm setting "recycle tween = true" in utility panel.
    but tweener create garbage every call...

    Code (CSharp):
    1. m_twMove = GetTransform().DOMove(ivecPosition.ToVector3(), fSpeed).SetUpdate(UpdateType.Fixed).OnComplete(()=> m_twMove = null);  // garbage 332 byte
    2.  
    3. or
    4.  
    5. GetTransform().DOMove(ivecPosition.ToVector3(), fSpeed); // garbage 232 byte
    스크린샷 2015-06-08 오후 10.22.40.png

    how to make grabage to 0?

    ps : if "recycle tween = false" , it makes 0.6k garbage every call.
     
  38. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    @MrEsquire No need to delete the old version every time. Just reimport DOTween over it, run the setup, and it will correctly update (and keep the existing settings). If you really want to delete it though, you can first set the Settings location to "Assets > Resources" (from DOTween Utility Panel), which will store the settings outside of DOTween/Demigiant's directories, so when you delete and reimport them they will be saved.

    @monogon I was gonna say you can't do it, but you made me realize that yes, indeed with Script Execution Order you can. Good call :)

    @bigcatsobig DOTween reduces allocations to the minimum, but there's still some needed when starting a new tween, even if minimal.
     
    exitsimulation likes this.
  39. Rustamovich

    Rustamovich

    Joined:
    Sep 5, 2014
    Posts:
    36
    @Izitmee Hi!
    I kill sequence in one script with "Sequencename1.Kill()" and somehow, sometimes it kills Sequencename2 in other script which plays in the same time with Sequencename1.

    What it could be?
    Thanks in advance
     
  40. Pinsukka

    Pinsukka

    Joined:
    Feb 17, 2014
    Posts:
    15
    @Izitmee Cool, I'll wait and see then, thanks a lot! :D
     
  41. bigcatsobig

    bigcatsobig

    Joined:
    Dec 9, 2014
    Posts:
    9
    @Izitmee
    Thank you for quick answers.
    even in the "recycle tween = true" DOMove () Will new tween is created internally at?
    Or tween is recycled, in order to apply the settings, do minimal allocation is performed?

    There is a question in addition.

    스크린샷 2015-06-09 오후 8.09.07.png

    DORotate is not complete if you set the update type to Fixed in the utility panel.

    Code (CSharp):
    1. GetTransform().DORotate(ivecPosition.ToVector3(), fSpeed); // Never Complete
    Set the update type to Normal, if you want to use the SetUpdate it will be successfully processed.

    Code (CSharp):
    1. GetTransform().DORotate(ivecPosition.ToVector3(), fSpeed).SetUpdate(UpdateType.Fixed); // OK
    I think there are some problems?
     
  42. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    @Rustamovich That is weird. Can you replicate it in a barebone example and send it to me? I can't replicate that issue here: everything works correctly.

    @Pinsukka The solution I had was evil and I scrapped it. But I'm still working on an alternative.

    @bigcatsobig The allocation is actually caused by the logic required to know what type of tween to recycle (in short, it's because of dictionaries). If you create a new tween that is the same type of another that was recycled (Vector3 for Vector3, float for float, etc) no new tween will be created though.

    About the FixedUpdate issue, my bad. Grab the update I'm attaching which fixes it (gonna release it officially as soon as I finish a couple more things). Remember to run again the Setup from DOTween's Utility Panel after overwriting the old version with the new one.
     

    Attached Files:

  43. GreenBoxInteractive

    GreenBoxInteractive

    Joined:
    Mar 23, 2015
    Posts:
    135
    I have a DOTween animation on a cube.

    I want to use OnMouseDown to trigger that animation, how would I do it?
     
  44. exitsimulation

    exitsimulation

    Joined:
    Feb 10, 2014
    Posts:
    82
    @Izitmee
    I am encountering a little problem with paths:
    I have a path with its orientation set to a look-at-point. This look-at-point is an empty gameobject with a small script that follows the y-position of the path-object (camera) so that the camera is always oriented horizontally. Now when the camera-path is nearing the look-at-point the camera starts stuttering, especially when the path movement is upwards.
    I am guessing this is caused by an Update problem between the moving camera and the (y-)following look-at-point. I tried to move the follow script of the look-at-point to LateUpdate but this did not help.
    Do you have any idea how to fix this?
     
  45. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    @GreenBoxInteractive Hi! You mean a DOTween Pro DOTweenAnimation, or a standard DOTween animation?

    In the first case, you'll need a reference to the DOTweenAnimation, and inside your OnMouseDown you will have to call:
    Code (csharp):
    1. myDOTweenAnimation.DOPlay();
    In the second case you will need a reference to the Tween, and write:
    Code (csharp):
    1. myTween.Play();
    @monogon Could you send me an example package, so I can test it out and see what's happening?
     
    GreenBoxInteractive likes this.
  46. GreenBoxInteractive

    GreenBoxInteractive

    Joined:
    Mar 23, 2015
    Posts:
    135
    Yes, the pro. How would I reference the tween?
     
  47. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    Create a public DOTweenAnimation variable on the MonoBehaviour that has the OnMouseDown, and drag the DOTweenAnimation gameObject there.

    Also, if you're using Unity's UGUI, you can even do that without code. Just use a UGUI button's Click event: drag the DOTweenAnimation gameObject as a target, then between the available methods choose DOPlay.
     
  48. GreenBoxInteractive

    GreenBoxInteractive

    Joined:
    Mar 23, 2015
    Posts:
    135
    I have a DOTween animation, rotating an object from 0 to 90 degrees when DOPlay(); is ran. Is there a way that instead of going from 0 to 90, then if I run it again, snapping back to 0, to make it go from 0 to 90, then when it's in the 90 pos, click again to get it to rotate from 90 to 180, and so forth.
     
  49. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    @GreenBoxInteractive I'm afraid that's not possible. If you set the LoopType to Incremental, the tween will actually move from 0 to 90, then 90 to 180, and so on. But only if you let it play continuously: restarting it will restart from the beginning.
     
  50. Cascho01

    Cascho01

    Joined:
    Mar 19, 2010
    Posts:
    1,347
    I have attached a camera on a DOTweenPath and now want to alter the speed during the flight, possible? Would be perfect with an Animation Curve.
     
    Last edited: Jun 11, 2015