Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice
  2. Ever participated in one our Game Jams? Want pointers on your project? Our Evangelists will be available on Friday to give feedback. Come share your games with us!
    Dismiss Notice

DOTween (HOTween v2), a Unity tween engine

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

  1. Izitmee

    Izitmee

    Joined:
    Jan 27, 2011
    Posts:
    3,233
    NEW UPDATE 0.8.180
    • NEW: Added material.DOColor/From shortcut overload that allows to tween named color properties

    @Reekdeb Now you can simply do:
    Code (csharp):
    1. renderer.material.DOColor(targetColor, "_TintColor", time);
     
  2. shlepsheed

    shlepsheed

    Joined:
    Mar 20, 2014
    Posts:
    10
    I cannot post the full code but the process is like this

    Code (CSharp):
    1. public GameObject A, B, C;    // Sprite
    2.     public int AnimTarget = 0;
    3.  
    4.     void Start ( ) {
    5.         DOTween.Init ( true, true, LogBehaviour.ErrorsOnly );
    6.     }
    7.  
    8.     void OnGUI ( ) {
    9.         if (GUILayout.Button ( "Next" )) {
    10.             NextButtonPressed ( );
    11.         }
    12.     }
    13.  
    14.     public void Animate ( ) {
    15.         if (AnimTarget == 0) {
    16.             A.renderer.material.DOFade ( 0f, 3f ).OnComplete( NextButtonPressed );
    17.         } else if (AnimTarget == 1) {
    18.             B.renderer.material.DOFade ( 0f, 3f ).OnComplete ( NextButtonPressed );
    19.         } else if (AnimTarget == 2) {
    20.             C.renderer.material.DOFade ( 0f, 3f ).OnComplete ( NextButtonPressed );
    21.         }
    22.     }
    23.  
    24.     public void NextButtonPressed ( ) {
    25.         DOTween.Complete ( );
    26.         Animate ( );
    27.         AnimTarget++;
    28.     }
    If i click the next button once there will no problem. But if i double click it i meet my problem. And if i do more click (With other gameobject, E, F, G maybe) it show exception.

    Code (CSharp):
    1. IndexOutOfRangeException: Array index is out of range.
    2. wrapper stelemref) object:stelemref (object,intptr,object)
    3. DG.Tweening.Core.TweenManager.ReorganizeActiveTweens () (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__DOTween.Assembly/DOTween/Core/TweenManager.cs:612)
    4. DG.Tweening.Core.TweenManager.Update (Single deltaTime, Single independentTime) (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__DOTween.Assembly/DOTween/Core/TweenManager.cs:128)
    5. DG.Tweening.DOTween.Update () (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__DOTween.Assembly/DOTween/DOTween.cs:96)
    Thanks for the help.
     
  3. Izitmee

    Izitmee

    Joined:
    Jan 27, 2011
    Posts:
    3,233
    I tried the code you just posted but everything works correctly here and I still can't replicate the issue. Can you:
    1. Download the latest version of DOTween (0.8.180), in case you're using an old one (you can see the version you're on by clicking on the [DOTween] gameObject while playing: the relative Inspector will show the current version among other infos).
    2. If you still have the issue after updating, can you try to replicate it (without the full code) in an empty project and attach it?
    Thanks :)

    EDIT: scrap the first point and go for for the second, since you should be already on v0.8.170 so that's not the case
     
  4. Little-Big-Monkey

    Little-Big-Monkey

    Joined:
    Mar 4, 2014
    Posts:
    35
    Heya Izitmee ^^

    I just found your new DOTween !
    Congratz, it's exactly what I was looking for as an HOTween update ;-)

    I will use it for my next project. However, I have a question, is there a visual editor yet ?
     
  5. Izitmee

    Izitmee

    Joined:
    Jan 27, 2011
    Posts:
    3,233
    Hey @Little Big Monkey! Thanks for the congratz and glad you like it. Visual Editor is not there yet, and I'm actually not even sure if I'll do it at all. But @Dávid Debnár is rolling his own DOTween Visual Editor, so who knows? ;)
     
  6. BTStone

    BTStone

    Joined:
    Mar 10, 2012
    Posts:
    1,155
    Heyho! Hows the PS Vita/PSM compatibility going on? :)
     
  7. shlepsheed

    shlepsheed

    Joined:
    Mar 20, 2014
    Posts:
    10
    @Izitmee Here the package, just spam the next button.

    Thanks
     

    Attached Files:

  8. Izitmee

    Izitmee

    Joined:
    Jan 27, 2011
    Posts:
    3,233
    @BTStone Heya!!! :) Since I can't test it directly on PSM, I'm waiting for the Ghostshark guys (who are porting Goscurry to mobile and PSM) to test it out, hoping they'll manage to get some more informative error logs, but first I have to finish implementing DOTween in the main project :B It's been a mess, but I hope to be done within next week (it's taking longer because while I implement it I realize I could add some new cool stuff and so I pause and do it).

    @shlepsheed Thanks, I managed to reproduce it and fix it. Can you test this last version (0.8.185) I'm attaching and see if everything's working on your side too?
    EDIT: sorry wrong version, see correct one below
     
    Last edited: Sep 9, 2014
    BTStone likes this.
  9. Izitmee

    Izitmee

    Joined:
    Jan 27, 2011
    Posts:
    3,233
    @shlepsheed Ok here we go, this is the good update (0.8.190) :) Sorry for the confusion
     

    Attached Files:

  10. shlepsheed

    shlepsheed

    Joined:
    Mar 20, 2014
    Posts:
    10
    Wow perfect thanks!
    Btw, are you forgot to remove Debug.Log()? I got some debug message with LogBehaviour.Default

    Thanks for the update.
     
  11. FuzzyBalls

    FuzzyBalls

    Joined:
    Jun 12, 2014
    Posts:
    47
    how can I get a object to rotate towards something with DOTween?

    I've tried this:

    Vector3 rotation = waypoints [waypointIndex].transform.position - this.transform.position;
    this.transform.DORotate (rotation, speed, true);

    but it doesn't really work :(
     
  12. Izitmee

    Izitmee

    Joined:
    Jan 27, 2011
    Posts:
    3,233
    @shlepsheed Actually I have to apologize once more. I made additional tests because I wanted to be sure I caught all, and I found another bug. I decided to scrap all the fixes I made with the last update and so something better (which seems to be working perfectly, but I'm gonna test a little bit more). New update coming in a short while.

    @FuzzyBalls You're using a position as a rotation, which is not the right way. You should calculate the rotation like this:
    Code (csharp):
    1. Vextor3 rotation = Quaternion.LookRotation(waypoints [waypointIndex].transform.position - this.transform.position, Vector3.up).eulerAngles;
    That said, if you wait a couple hours I'll fix this bug I'm working on and also add a DORotateTowards shortcut ;)
     
  13. shlepsheed

    shlepsheed

    Joined:
    Mar 20, 2014
    Posts:
    10
    @Izitmee Don't worry thanks for your work. Good luck ;)
     
  14. Izitmee

    Izitmee

    Joined:
    Jan 27, 2011
    Posts:
    3,233
    NEW UPDATE 0.8.200 (merged with previous update)
    • NEW: Added trasform/rigidbody.DORotateTowards
    • NEW: Added material.DOColor/From overload that allows to tween named color properties
    • BUGFIX: Fixed filtered operations causing exceptions in some rare cases
    NOTE: I might change the DORotateTowards method name to DOLookAt in the next update (so I can add a DOLookFrom instead than a DORotateTowardsFrom which sounds ugly), but I have to think about it.

    @shlepsheed This truly fixes the bug you found! Honestly! Bug no more! :D

    @FuzzyBalls Now you can just do:
    Code (csharp):
    1. transform.DORotateTowards(waypoints[waypointIndex].transform.position, speed, true);
     
  15. BTStone

    BTStone

    Joined:
    Mar 10, 2012
    Posts:
    1,155
    Alright. I guess we'll just use HOTween for this project, since it works without problems on the Vita (for now! :p ), and move to DOTween after that :)
     
  16. Izitmee

    Izitmee

    Joined:
    Jan 27, 2011
    Posts:
    3,233
    Sorry I couldn't push DOTween's Vita compatibility in time :/ By the way, if you want and have the time, I'd suggest making one last try with the last version. I made some compatibility changes in the past couple weeks, even if I didn't test them, and it might work!
     
  17. shlepsheed

    shlepsheed

    Joined:
    Mar 20, 2014
    Posts:
    10
    @Izitmee Yes the bug is fixed thanks, your awesome!
     
  18. BTStone

    BTStone

    Joined:
    Mar 10, 2012
    Posts:
    1,155
    Woah, no need to apologize! Since HOTween does the job, everything is working out great :D

    I will do the test, yes!
     
  19. BTStone

    BTStone

    Joined:
    Mar 10, 2012
    Posts:
    1,155
    Eh, yeah. It worked :D

    I hope I did everything right.

    - downloaded the latest DOTween from your website
    - put the DOTween Folder in my AssetFolder
    - downloaded the compatibility-test package from the other topic
    - imported ONLY the Scene, since the DOTween.dll weren't uptodate (were they?)
    - switched Plattform Settings, Build&Run the scene on the PS Vita
    -> the cube rotates and splits into multiple cubes and the DOTween-Sprite fades in

    Seems to work pretty fine :D
     
    Izitmee likes this.
  20. Izitmee

    Izitmee

    Joined:
    Jan 27, 2011
    Posts:
    3,233
    Wohoooo!!! You did awesomely!!!! Thank you, that is great news! :) I'm gonna update the various info then!
     
  21. coolbird22

    coolbird22

    Joined:
    Mar 20, 2014
    Posts:
    38
    Hi @Izitmee, first off, let me thank you for this wonderful tweener ! This looks so very helpful.
    I'm having some n00b doubts that I hope you might be able to vanquish. I went through the documentation on the site and yet I might need some help. I have a 2d grid based array, with walkable and unwalkable grids (array elements). The walkable grids have a value of 0 assigned to them, while the unwalkable have been assigned a value of 1, to stop the player from going into the unwalkable grid. My current script basically teleports the player onto the corresponding grid depending on the direction pressed, which then checks if that grid is walkable or unwalkable. And in case if it is unwalkable, it sends the player back to the previous grid. Since my script is basically making the player teleport to the new grid, it doesn't need to wait for the final position values to come true (during using tween) and hence works fine. Could you perhaps point me in the right direction to getting something like this to work ?
    The below is the code that I'm using for the player.

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class player : MonoBehaviour {
    5.  
    6.     public GameObject levelCreator_;
    7.     levelCreator temp;
    8.     public Vector2 playerPos;
    9.    
    10.     int[,] mapArray = new int[13,17];
    11.  
    12.     void Start () {
    13.         levelCreator_ = GameObject.Find ("LevelCreatorGameObject");
    14.         temp = levelCreator_.gameObject.GetComponent<levelCreator>();
    15.         mapArray = temp.mapArray;
    16.         for(int i = 1; i<12; i++)
    17.         {
    18.             for(int ii = 1; ii < 16; ii++)
    19.             {
    20.                 if( mapArray[i,ii] == 2)               //Checking for a grid with value 2 to mark that grid as players start position
    21.                 {
    22.                     playerPos = new Vector2(i,ii);
    23.                 }
    24.             }
    25.         }
    26.         transform.position = new Vector3(playerPos.x,0,playerPos.y);
    27.     }
    28.    
    29.     void Update () {
    30.         if (gameObject.CompareTag("alive"))
    31.             getInput();
    32.     }
    33.    
    34.     void getInput()
    35.     {
    36.         Vector2 oldPos = playerPos;
    37.  
    38.         if(Input.GetKeyDown("up"))
    39.         {
    40.               playerPos += new Vector2(-1,0);
    41.         }
    42.         if(Input.GetKeyDown("down"))
    43.         {
    44.             playerPos += new Vector2(1,0);
    45.         }
    46.         if(Input.GetKeyDown("left"))
    47.         {
    48.             playerPos += new Vector2(0,-1);
    49.         }
    50.         if(Input.GetKeyDown("right"))
    51.         {
    52.             playerPos += new Vector2(0,1);
    53.         }
    54.        
    55.         if(mapArray[(int)playerPos.x,(int)playerPos.y] == 1) //Checking if grid is unwalkable
    56.         {
    57.             playerPos = oldPos;
    58.         }
    59.         transform.position = new Vector3(playerPos.x,0,playerPos.y);
    60.     }
    61. }
     
  22. Izitmee

    Izitmee

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

    I'm not 100% sure of what you're asking, but if I understood it correctly, you could rewrite your getInput method like this:
    Code (CSharp):
    1. void getInput()
    2. {
    3.    // This stays the same but let's make oldPos a Vector3
    4.    Vector3 oldPos = playerPos;
    5.    if(Input.GetKeyDown("up"))
    6.    {
    7.          playerPos += new Vector2(-1,0);
    8.    }
    9.    if(Input.GetKeyDown("down"))
    10.    {
    11.        playerPos += new Vector2(1,0);
    12.    }
    13.    if(Input.GetKeyDown("left"))
    14.    {
    15.        playerPos += new Vector2(0,-1);
    16.    }
    17.    if(Input.GetKeyDown("right"))
    18.    {
    19.        playerPos += new Vector2(0,1);
    20.    }
    21.    // Now we tween to the new position in 1 second
    22.    // and add a callback which will check the new position when the tween ends
    23.    transform.DOMove(new Vector3(playerPos.x,0,playerPos.y), 1)
    24.       .OnComplete(()=> CheckPosition(oldPos));
    25. }
    26.  
    27. // This method is called when a move tween ends,
    28. // and decideds if the transform should stay where it is
    29. // or if it should be tweened to its previous position
    30. void CheckPosition(Vector3 oldPos)
    31. {
    32.    if(mapArray[(int)transform.position.x,(int)transform.position.y] == 1) //Checking if grid is unwalkable
    33.    {
    34.       // Tween to old position in 1 second
    35.       transform.DOMove(oldPos, 1);
    36.    }
    37. }
    38.  
     
  23. Seith

    Seith

    Joined:
    Nov 3, 2012
    Posts:
    726
    Hello, long-time iTween user here. I'm now making the jump to DOTween and so far I'm loving it! Keep up the great work! :)
     
  24. Izitmee

    Izitmee

    Joined:
    Jan 27, 2011
    Posts:
    3,233
    Hi @Seith and welcome thanks! Glad you're liking it :)
     
  25. Izitmee

    Izitmee

    Joined:
    Jan 27, 2011
    Posts:
    3,233
  26. coolbird22

    coolbird22

    Joined:
    Mar 20, 2014
    Posts:
    38
    Hi @Izitmee, I tried what you suggested. It is still doing the same thing as before. The player object tweens to the unwalkable grid, and then checks if the grid is unwalkable, and then comes back to its previous place, whereas it shouldn't have started to proceed towards that grid.
    But, this is a coding inefficiency on my part, and not a problem with DOTween, and I don't wish to spam your thread any more. Though big thanks for making such a cool tool available for everyone ! Much appreciated.
     
  27. Izitmee

    Izitmee

    Joined:
    Jan 27, 2011
    Posts:
    3,233
    @coolbird22 Oh I actually thought you wanted the player to walk and then come back. Doing what you just said instead is much easier (I will forgive myself now for spamming my thread ;))

    When you check if the grid is unwalkable you shouldn't do anything, since the transform is already in the right position. When instead you find it walkable you create the tween and move it to the new playerPos:
    Code (csharp):
    1. transform.DOMove(playerPos, 1);
    (if I got confused once again and you want to open a thread for this question let me know here, and I'll come to see if I may help)
     
  28. shlepsheed

    shlepsheed

    Joined:
    Mar 20, 2014
    Posts:
    10
    Thanks @Izitmee my game is run like it's planned. There some debug message is called when i use
    Code (CSharp):
    1. ScriptSequence.IsPlaying()
    It say
    Code (CSharp):
    1. DOTWEEN :: This Tween has been killed and is now invalid
    2. UnityEngine.Debug:LogWarning(Object)
    3. DG.Tweening.Core.Debugger:LogWarning(Object) (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__DOTween.Assembly/DOTween/Core/Debugger.cs:22)
    4. DG.Tweening.Core.Debugger:LogInvalidTween(Tween) (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__DOTween.Assembly/DOTween/Core/Debugger.cs:36)
    5. DG.Tweening.TweenExtensions:IsPlaying(Tween) (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__DOTween.Assembly/DOTween/TweenExtensions.cs:348)
    6.  
    Just want to report that, Thanks.
     
  29. Izitmee

    Izitmee

    Joined:
    Jan 27, 2011
    Posts:
    3,233
    Glad everything is working correctly now :)

    About the warning you get, it's there on purpose (to tell you that you're trying to access a tween that is now invalid) because your warning level is set to LogBehaviour.Default (which means both errors and warning). You can deactivate it by setting DOTween's logBehaviour to LogBehaviour.ErrorsOnly during DOTween.Init().

    EDIT: do you think I should set the log behaviour to ErrorsOnly by default? Let me know.
     
  30. shlepsheed

    shlepsheed

    Joined:
    Mar 20, 2014
    Posts:
    10
    Seems like i don't read a lot about the LogBehaviour thanks.

    IMO for prototyping I'll like show ErrorOnly because warning from DOTween is not very significant for me. So i'll focus on my program (I believe DOTween will work how it should do). Except if the code i wrote is not work like it should be then i change the log behaviour then. Well, that's when i don't call Init at the first of the app.

    Edit : There no problem with the DOTween now. Keep the great work
     
    Last edited: Sep 11, 2014
  31. Izitmee

    Izitmee

    Joined:
    Jan 27, 2011
    Posts:
    3,233
    Great. In the next update I'll change logBehaviour to be ErrorsOnly by default. Makes more sense after all.
     
  32. Seith

    Seith

    Joined:
    Nov 3, 2012
    Posts:
    726
    Hello, I have a question: is there a way to make tweens independent from the Time.timeScale setting? It seems that when it is set to 0 (or a very low value) to pause the game, then the tweens don't occur in real-time anymore...
     
  33. Izitmee

    Izitmee

    Joined:
    Jan 27, 2011
    Posts:
    3,233
    Absolutely. All tweens depend on Unity's Time.timeScale by default, but if you set their UpdateType to Independent they will ignore it completely (but will still depend on DOTween's timeScale, which you can set via the DOTween.timeScale static property).

    Example:
    Code (csharp):
    1. transform.DOMoveX(4, 1).SetUpdate(UpdateType.Independent);
     
  34. Seith

    Seith

    Joined:
    Nov 3, 2012
    Posts:
    726
    Fantastic! That works beautifully, thank you!
     
  35. Izitmee

    Izitmee

    Joined:
    Jan 27, 2011
    Posts:
    3,233
    Great. By the way, I just realized you're the (or one of the, but mostly THE) Ghost of a Tale guy! Wah! I was talking about it just a few days ago and was obviously very impressed since the first time (long ago) I saw a video. Keep up the good work :)
     
  36. Seith

    Seith

    Joined:
    Nov 3, 2012
    Posts:
    726
    He he, I am! That's nice to hear, thanks! :)
     
  37. silentslack

    silentslack

    Joined:
    Apr 5, 2013
    Posts:
    270
    Hi really enjoying the new DOTween, great work :)

    However, I can't see where I can set the Update tick of the tween. I would like the tween to happen post-animations so I want it to execute in LateUpdate. Is there a param for this?

    Ta!
     
  38. Izitmee

    Izitmee

    Joined:
    Jan 27, 2011
    Posts:
    3,233
    @silentslack Glad you like it :) There's no LateUpdate option for now. I thought about that a lot, but adding a LateUpdate option would forcefully make things less efficient (even if slightly so) in order to distinguish regular and late update tweens. Instead, if you want to call all tweens after any other Update event, you can just set the Script Execution Order of the DOTween class so it's after the basic ones. Let me know what you think of this solution.
     
  39. silentslack

    silentslack

    Joined:
    Apr 5, 2013
    Posts:
    270
    Doesn't sound ideal to me. Putting the script execution after the default time does not overwrite an Animation component. It must execute post-update in the LateUpdate function. I'm adding random finger animation over the top of keyframed animation. Dang :(
     
  40. Izitmee

    Izitmee

    Joined:
    Jan 27, 2011
    Posts:
    3,233
    Mhmm that's a good point. I'm adding LateUpdate to my TODO list and see if I can come out with a valid solution ;)
     
  41. silentslack

    silentslack

    Joined:
    Apr 5, 2013
    Posts:
    270
    Ok awesome, I'll put a TODO on my list for updating the script when your TODO is done ;)

    Thanks buddy. Don't spend your $5 all at once!
     
  42. svope

    svope

    Joined:
    Jul 6, 2014
    Posts:
    8
    Hi guys,

    I would like to ask you how to make gameobject move along this path ( just random example).



    I think that to achieve this tweening engine must support bezier curves, am I right? ( like iTween, LeanTween..) Or is there any other ( easy/straightforward ) way how to do it in DOTween? I'm just very new to Unity etc. and trying to choose the right tool.
    Thank you !
     

    Attached Files:

  43. Izitmee

    Izitmee

    Joined:
    Jan 27, 2011
    Posts:
    3,233
  44. Izitmee

    Izitmee

    Joined:
    Jan 27, 2011
    Posts:
    3,233
    P.S. by the way, I think this is the right moment to say I'm working on a Visual Path Editor (only for the said Pro version), though right now I'm struggling with some Unity bugs that are trying to prevent me to make it as nice as I'd want it to be. But I will prevail! :p
     
  45. RichHurst

    RichHurst

    Joined:
    Jul 25, 2013
    Posts:
    30
    @Izitmee sounds like the pro version is close, but let me know if you need some more people to test it prior to its release (also happy to pay for pro version early)
     
  46. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    2,311
    Whaaaaaat? I'm curious to see what you've got going there :) Are you willing to share a very rough feature/idea overview of that to prevent heart attacks on my side?
     
  47. Izitmee

    Izitmee

    Joined:
    Jan 27, 2011
    Posts:
    3,233
    @RichHurst Thank you a lot for the support Rich, I'm gonna take advantage of your offer soon (I hope) ;)

    @Baroni Ahahah nooo don't worry :D It's nothing compared to SWS: just a single "per object" path editor. Since the path plugin will be in the Pro version, I felt like I needed to add something more to it. Gonna send it to you as soon as it's testeable, and by the way I'm gonna write you a PM now because while developing it I got some nifty ideas you might add to SWS, if you like ;)
     
  48. RichHurst

    RichHurst

    Joined:
    Jul 25, 2013
    Posts:
    30
    @Izitmee no worries, it's great to have such a useful tool... just let me know if I can help.
     
  49. Izitmee

    Izitmee

    Joined:
    Jan 27, 2011
    Posts:
    3,233
    NEW UPDATE 0.8.260
    • NEW: Added UpdateType.Late, which uses Unity's LateUpdate
    • NEW: Added DOTween.TotPlayingTweens method
    • NEW: Added Documentation and Check Updates buttons in DOTween Inspector
    • CHANGE: UpdateType.Independent removed: it is now an additional option when using SetUpdate (so that both Default and Late updates can be independent)
    • CHANGE: logBehaviour is now set to LogBehaviour.ErrorsOnly by default
    NOTE: please beware of the API change
    Since UpdateType.Independent has been removed, to make your tweens independent instead than this:
    Code (csharp):
    1. myTween.SetUpdate(UpdateType.Independent);
    you will now have to do this:
    Code (csharp):
    1. myTween.SetUpdate(true);
    I made this change because this way both Default and Late tweens can be independent, like this:
    Code (csharp):
    1. myTween.SetUpdate(UpdateType.Late, true);

    @silentslack LateUpdate (UpdateType.Late), voilà! ;)
     
  50. silentslack

    silentslack

    Joined:
    Apr 5, 2013
    Posts:
    270
    Awesome and looks like you didn't affect performance :) Thanks dude!
     
unityunity