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

    meapps

    Joined:
    May 21, 2013
    Posts:
    167
    @Izitmee i want to attached DOTweenAnimation to an gameobject. But how can I setup the fading etc via script.
    Any example?
     
  2. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    @Cascho01 Hi. You can change the internal timeScale of a tween to speed it up or down. To do that, grab the tween reference from your DOTweenPath (using myDOTweenPath.GetTween()), then change its timeScale:
    Code (csharp):
    1. Tween pathTween = myDOTweenPath.GetTween();
    2. // Change to x2 speed
    3. pathTween.timeScale = 2;
    As a hint, consider that you can also tween the timeScale of a tween, to make smoother changes:
    Code (csharp):
    1. DOTween.To(()=>pathTween.timeScale, x=>pathTween.timeScale = x, 2, 1);
    @meapps If you want to set a fade via script you should create the tween itself via script instead than with a DOTweenAnimation. There are various DOFade methods for each type of target, in case it's a material, a text, a sprite, etc. For example, with a material:
    Code (csharp):
    1. myMaterial.DOFade(0, 1);
     
    meapps likes this.
  3. meapps

    meapps

    Joined:
    May 21, 2013
    Posts:
    167
    @meapps If you want to set a fade via script you should create the tween itself via script instead than with a DOTweenAnimation. There are various DOFade methods for each type of target, in case it's a material, a text, a sprite, etc. For example, with a material:
    Code (csharp):
    1. myMaterial.DOFade(0, 1);
    [/QUOTE]

    @Izitmee

    I spawn an gameobject and add it as an child. I tried DoJump too and have some issues. I don't know how it works
    my figure is moving and I want that the block jumps a bit if they got attached.
    I will make a small video. What I mean...
     
  4. djgriff

    djgriff

    Joined:
    May 29, 2014
    Posts:
    279
    Hi, I am struggling to get DOTween to work as i want it.. I am new to Unity and DOTween but i have come from Java libgdx platform. However, I have 3 simple tweens 2 are a sequence and one is a straight up move tween. Code:
    Code (csharp):
    1.  void Update ()
    2.     {
    3.         breathCount = (int)touchCount.breathNumber;
    4.         textNum.text = breathCount.ToString ();
    5.         if (playedOnce == false) {
    6.             PlayTween ();
    7.         }
    8.     }
    9.  
    10.     public void TransPortObject ()
    11.     {
    12.         //this.transform.position = new Vector3 (transform.position.x, transform.position.y, 100);
    13.         //
    14.         DOTween.RestartAll ();
    15.      
    16.         print ("REst the tween has fired.. asif");
    17.     }
    18.  
    19.  
    20.     public void PlayTween ()
    21.     {
    22.  
    23.         if (touchCount.state == touchCount.State.START) {
    24.                         textNumber.DOMove (new Vector3 (transform.position.x, transform.position.y, 100), breathCount);
    25.             textNumber.GetComponent<MeshRenderer> ().material.color = new Color (1, 1, 1, 0);
    26.             s.Append (textNumber.GetComponent<Renderer> ().material.DOFade (1, touchCount.breathTime / 4));
    27.              
    28.             s.Append (textNumber.GetComponent<Renderer> ().material.DOFade (0, touchCount.breathTime / 4 * 2).SetDelay (touchCount.breathTime / 4));
    29.          
    30.             playedOnce = true;
    31.          
    32.         }
    33.      
    34.     }
    Update calls the playTween(); then the transPortObject(); is top reset the Tweens. RestartAll();
    But they are not restarting..

    I have been over the example scripts to no joy and tried all kinds of resetting the transform position to adding loops yoyo, restart.. and nothing works..

    Something is up and i cant figure out how to simple restart the tweens. normal DoMove and 2 sequences.


    the transportObject(); is called every time the set variable time is completed.

    This is the entire Script:

    Code (csharp):
    1. using UnityEngine;
    2. using System.Collections;
    3. using DG.Tweening;
    4. using UnityEngine.UI;
    5. public class numberScript : MonoBehaviour
    6. {
    7.  
    8.  
    9.     public Transform textNumber;
    10.     public bool playedOnce = false;
    11.     public Sequence s;
    12.     public TextMesh textNum;
    13.     private int breathCount;
    14.     void Start ()
    15.     {
    16.         s = DOTween.Sequence ();
    17.         textNumber.GetComponent<MeshRenderer> ().material.color = new Color (1, 1, 1, 0);
    18.         //textNumber.GetComponent<Renderer>().material.SetColor()
    19.         textNum = gameObject.GetComponent<TextMesh> ();
    20.      
    21.     }
    22.  
    23.     // Update is called once per frame
    24.     void Update ()
    25.     {
    26.         breathCount = (int)touchCount.breathNumber;
    27.         textNum.text = breathCount.ToString ();
    28.         if (playedOnce == false) {
    29.             PlayTween ();
    30.         }
    31.     }
    32.  
    33.     public void TransPortObject ()
    34.     {
    35.         //this.transform.position = new Vector3 (transform.position.x, transform.position.y, 100);
    36.         //
    37.         DOTween.RestartAll ();
    38.      
    39.         print ("REst the tween has fired.. asif");
    40.     }
    41.  
    42.  
    43.     public void PlayTween ()
    44.     {
    45.  
    46.         if (touchCount.state == touchCount.State.START) {
    47. textNumber.DOMove (new Vector3 (transform.position.x, transform.position.y, 100), 0);
    48.             textNumber.GetComponent<MeshRenderer> ().material.color = new Color (1, 1, 1, 0);
    49.             s.Append (textNumber.GetComponent<Renderer> ().material.DOFade (1, touchCount.breathTime / 4));
    50.              
    51.             s.Append (textNumber.GetComponent<Renderer> ().material.DOFade (0, touchCount.breathTime / 4 * 2).SetDelay (touchCount.breathTime / 4));
    52.          
    53.             playedOnce = true;
    54.          
    55.         }
    56.      
    57.     }
    58. }[code]
    59.  
    60.  
    61. please excuse the messy code.
    62.  
    63.  
    64. I hope someone can point me in the right direction.. just dont understand why i am having such problems with it.
    65.  
    66. Thanks
     
  5. Ben-BearFish

    Ben-BearFish

    Joined:
    Sep 6, 2011
    Posts:
    1,204
    After importing DoTween Pro, to organize my folders, I drag the Demigiant folder into a subfolder. Now with the latest update I receive an error. Could you put it back so we can drag the plugin into a subfolder?
     
  6. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    @djgriff Hi! In order to reuse a Tween/Tweener/Sequence, you have to set it's autoKill state to false, otherwise it will be automatically deleted as soon as it finishes, in order to free up memory. Chain a SetAutoKill(false) to your Sequence and it will work.
    Code (csharp):
    1. s = DOTween.Sequence().SetAutoKill(false);

    @Ben BearFish I just tried to move the DOTween Pro folder in another directory, but I get no errors. Are you sure you don't have two copies of DOTween in different directories? DOTween Pro comes with the standard version of DOTween included.
     
  7. Ben-BearFish

    Ben-BearFish

    Joined:
    Sep 6, 2011
    Posts:
    1,204
    Perhaps, I'll have to check later. Could I ask you, did you move the folder before or after you selected the Setup DoTween tab option?
     
    Last edited: Jun 16, 2015
  8. Trung-Hieu

    Trung-Hieu

    Joined:
    Feb 18, 2013
    Posts:
    37
    Hi all,

    I have a generic tween:
    DOTween.To (() => float.Parse (target.text), x => target.text = x.ToString ("F0"), countTo, duration);

    How am I supposed use Complete method on this tween?
     
  9. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    @Ben BearFish I tried both ways successfully.

    @Trung Hieu Hi! You need to store a reference to that tween. Like this:
    Code (csharp):
    1. myTween = DOTween.To (() => float.Parse (target.text), x => target.text = x.ToString ("F0"), countTo, duration);
    and then you can do:
    Code (csharp):
    1. myTween.Complete();
     
    Trung-Hieu and Ben-BearFish like this.
  10. achooley

    achooley

    Joined:
    Sep 6, 2013
    Posts:
    17
    Hi. I have a problem with movement(RectTransform.DOAnchorPos).This movement is not smooth. I have tested with enabled and disabled snap. How can i make it smoother?
     
    Last edited: Jun 17, 2015
  11. Trung-Hieu

    Trung-Hieu

    Joined:
    Feb 18, 2013
    Posts:
    37
    Hi I tried that but to no avai, may I know that variable type of myTween ?

    Here is my code:

    Code (csharp):
    1.  
    2. using UnityEngine;
    3. using UnityEngine.UI;
    4. using DG.Tweening;
    5.  
    6. public class ScoreCountOnEnable : MonoBehaviour {
    7.     public enum ScoreType {
    8.         KILL_COUNT,
    9.         HEADSHOT_COUNT,
    10.         LEVEL_AWARD,
    11.         TOTAL_SCORE
    12.     }
    13.  
    14.     [Tooltip ("The score type that will be retrieved")]
    15.     public ScoreType scoreType;
    16.  
    17.     [Tooltip ("Target uGUI Text component to display the score")]
    18.     public Text target;
    19.  
    20.     [Tooltip ("The count animation duration")]
    21.     public float duration;
    22.  
    23.     [Tooltip ("Should the animation be independent from Time.timeScale")]
    24.     public bool unscaledTime = false;
    25.  
    26.     /** The final value of the count */
    27.     private float countTo = 0F;
    28.     /** The tween that will be used to do counting animation*/
    29.     private Tween tween = null;
    30.  
    31.     private void OnEnable () {
    32.  
    33.         // Retrieve the score of the specified score type and store inside countTo
    34.         switch (scoreType) {
    35.             case ScoreType.KILL_COUNT:
    36.                 countTo = PlayingDataManager.Instance.zombieKilled;
    37.                 break;
    38.             case ScoreType.HEADSHOT_COUNT:
    39.                 countTo = PlayingDataManager.Instance.zombieHeadShot;
    40.                 break;
    41.             case ScoreType.LEVEL_AWARD:
    42.                 countTo = PlayingDataManager.Instance.levelAward;
    43.                 break;
    44.             case ScoreType.TOTAL_SCORE:
    45.                 countTo = PlayingDataManager.Instance.earnedCoins;
    46.                 break;
    47.             default:
    48.                 countTo = 0F;
    49.                 break;
    50.         }
    51.  
    52.         // Reset the target text to 0 first
    53.         target.text = "0";
    54.  
    55.         // Start tweening the text from 0 to count to
    56.         tween = DOTween.To (() => float.Parse (target.text), x => target.text = x.ToString ("F0"), countTo, duration)
    57.                 .SetUpdate (UpdateType.Normal, isIndependentUpdate: unscaledTime);
    58.  
    59.  
    60.     }
    61.  
    62.     /** Immediately complete the counting animation */
    63.     public void Complete () {
    64.         // TODO: Should only complete its own tween
    65.         // DOTween.CompleteAll ();
    66.         tween.Complete ();
    67.     }
    68. }
    69.  
     
  12. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    @achooley The tween itself is not a problem in your case. But consider that, when moving UGUI objects, Unity has to recalculate a lot of things (UGUI is still not very efficient), so if your Canvas contains lots of children that might be the reason of the jerkiness.

    @Trung Hieu Your code seems correct to me, and "tween" should indeed be of type Tween. Consider that Complete will do nothing if the tween is already complete (because it will have been killed automatically, unless you set autoKill to false), but that should obviously not be a problem in your case.
    The only reason why Complete is not working as intended is that it's called before you create the tween?
     
  13. achooley

    achooley

    Joined:
    Sep 6, 2013
    Posts:
    17
    Thx for reply)
     
  14. Sonoshee

    Sonoshee

    Joined:
    Jul 8, 2014
    Posts:
    77
    DOTween is absolutely amazing, I used to go through the trouble of creating an animator and setting it up just for a simple scaling or rotation animation, now it's not taking more than 5 seconds to get the animation working.
    I just have a small question, is it possible to access the members of a DOTween Animation in DOTween Pro that are visible in the inspector ? ( duration, delay, ignore timescale, ease...). I really need it to implement an effect in my game, any help ? ( I need to alter the duration based on the distance from an object, done through code)
     
  15. Sonoshee

    Sonoshee

    Joined:
    Jul 8, 2014
    Posts:
    77
    Oh never mind, I didn't declare the use of the DG.Tweening namespace. You also need to set the the members inside a function of choice called from within the Events feature of the DOTween Animation component ( OnUpdate, OnStart, OnStep...)
     
  16. Trung-Hieu

    Trung-Hieu

    Joined:
    Feb 18, 2013
    Posts:
    37
    Thanks for your reply. I did actually check and ensure that Complete is called during the tween, not before.
    By the way, the scene I am testing with is having Time.timeScale set to very close to 0, may that be the one that causing problem?
     
  17. puzzlekings

    puzzlekings

    Joined:
    Sep 6, 2012
    Posts:
    404
    Hi

    I just tried upgrading my project to 5.1.1 and I am seeing this:

    Assets/Demigiant/DOTweenPro/DOTweenTextMeshPro.cs(136,44): error CS0246: The type or namespace name `TextMeshProUGUI' could not be found. Are you missing a using directive or an assembly reference?

    Not sure whether it is a DoTween problem or a TMPro problem?

    DOTween utility panel comes up but it is all blank - I think I am running DOTweenPro_0_9_255 - any ideas what I can do?


    cheers

    Nalin

    EDIT FYI this error went away after upgrading to the latest TMPro and latest DoTween :)

     
    Last edited: Jun 19, 2015
  18. Dragonic89

    Dragonic89

    Joined:
    Jan 3, 2013
    Posts:
    48
    Hi,

    I have a problem about performance with transform.DOKill() !

    In my project I had to destroy many gameobjects (shoot'em up : bullets reaching game screen limits), with an active tween on them, at the same time. For this I used "Destroy(gameobject)".

    But now I'm trying to implement a pooling system in my project so I have to disable and store the gameobject in a List. I have to stop the tween if the gameobject is stored, so I apply DOKill() when I have to store it ! But now I can see huge spikes with the profiler when bullets start to be stored, only if I use DOKill (with a stress test scene and thousand of bullets ^^) !

    I think I can't store the Tween and reuse it later because each time I take a bullet from the pooling system I can apply one or more different tweens !


    EDIT : when I store the ref to the tween and do only tween.Kill() I don't have the performance problem ! Does the performance issue comes from the search of all tweens with transform.DOKill() ?
     
    Last edited: Jun 30, 2015
  19. BTStone

    BTStone

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

    which version should I download

    DOTween Pro [pre-release] 0.9.295d
    or
    DOTween Pro 0.9.290 ?

    What does pre-release mean exactly?

     
  20. achooley

    achooley

    Joined:
    Sep 6, 2013
    Posts:
    17
    I added a canvas to balls tube (tube contain max 8 balls, i think its not a lot) and the result is not changed. How can I improve the smoothness?
     
  21. shaderbytes

    shaderbytes

    Joined:
    Nov 11, 2010
    Posts:
    900
    Hey Dan

    Long time ;) I finally got round to upgrading to Dotween! You really made it awesome now congrats. Im going to be testing your new overlapping sequences functionality soonish as this was something I had to work around previously with Hotween. (Pinball light sequences ) Of coarse I will send you a demo of it in action once its completed ;)
     
  22. SidarVasco

    SidarVasco

    Joined:
    Feb 9, 2015
    Posts:
    163
    Using DTPro im having difficulty using Localmove and the "From" option on my ugui element. I want my object to move from the center to its current position. It does start at the center but it then moves to a position that's not even remotely close to its initial position. Am I missing something?


    BTW, before DTPro I tried making something similar and added the option to tween the children as well. Like for having a menu list of buttons and animate them in " From > To" relative to their original position. Maybe something like that would be neat for DTPro.


    Edit:



    This doesn't seem to work. Even if I set On Enable to Play. When I enable my object the tweens are not triggered.
     
    Last edited: Jun 26, 2015
  23. Logan_Booker

    Logan_Booker

    Joined:
    Jun 20, 2013
    Posts:
    3
    Hey @lzitmee, hopefully this a simple request!

    I'm currently using DOTween to handle the rotation of a gauge, the problem is it always takes the shortest path around. As you can understand, this isn't ideal for a gauge, where the start and end rotations can be quite close together, and the dial should rotate the "long way around", so to speak.

    I had a play around with the DORotate flags (Fast, FastBeyond360, etc) and couldn't get the desired behaviour. Now, I can code this myself without using DOTween, but I'd rather keep everything consistent.

    So, is there something I'm missing in the current version of DOTween that does this and if not, is there a workaround?
     
    FlightOfOne and jprocha101 like this.
  24. slimshader

    slimshader

    Joined:
    Jun 11, 2013
    Posts:
    187
    Hey, how to integrate DOTween with custom Timers (like in Chronos Time Control package) ?
     
  25. Maeslezo

    Maeslezo

    Joined:
    Jun 16, 2015
    Posts:
    325
    Hello!!

    Thank you for this amazing asset.

    I am trying to make "DoLookAt" work with a 2D sprite render but I dont get it. I have tried with the constrains but nothing.

    In this case, what I would need is lookAt(target) points the Up vector of the sprite to the target.

    Is this possible somehow?

    Thank you!!
     
  26. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    Agh! Apologies ladies and gentlemen!
    Once more the notification system broke and I wasn't receiving notifications for new posts (and I was so busy that I forgot to check anyway). Sorry sorry!

    @Sonoshee Glad you solved it in the meantime, and glad you like DOTween!

    @puzzlekings Glad you solved it too! Older version of TextMeshPro didn't have the TextMeshProUGUI object, and that's where the issue was

    @BTStone Heya! :) Always get the latest version, pre-release or not. Pre-release is just the way I categorize versions that have only one change. When I have many of them I will delete the pre-releases and publish a "full version with all the changes". This is to make the changelog easier to read.

    @achooley I'm afraid there's not much else you can do, other than use non-UGUI sprites for that. Still, you could try enabling the new "Smooth DeltaTime" option in DOTween's Utility Panel. That will try to keep a smoother framerate even if Unity doesn't. Might be worth a try.

    @shaderbytes Heyyyyy!!! Glad you like it, dance master :) Can't wait to see the demo

    @Logan_Booker FastBeyond360 should give you exactly the rotation you want. For example:
    Code (csharp):
    1. transform.DORotate(new Vector3(0, 0, -358), 1, RotateMode.FastBeyond360);
    dorotate_fastbeyond360.gif

    @slimshader I have no idea because I don't use them :B But a user was making some tests to see if he managed, or could give me a hint on what to implement.

    @Maeslezo To Hello! make DOLookAt work correctly in 2D, you should set the PathMode (in the DOPath method) to TopDown2D or Sidescroller2D, depending on your type of movement.

    @Dragonic89 Yup, your final consideration is right :) DOKill is an extension method, and thus looks through all existing tweens to find the one with the given target, THEN kills it. Storing the tween and then calling Kill directly is definitely the right choice if you have tons of tweens running.

    @Trung Hieu The "almost 0" timeScale shouldn't really be a problem. Can you send me an example package that replicates the issue, so I can check what's happening?

    @SidarVasco I'm making some tests right now. Will get back to you in a short while.

    Again, apologies to everyone for the delayed replies.
     
  27. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
  28. cranecam

    cranecam

    Joined:
    Nov 25, 2013
    Posts:
    25
    hello,

    I couldn't find a sample on how to rotate a RectTransform with an image component around the z axis, any idea?
     
  29. cranecam

    cranecam

    Joined:
    Nov 25, 2013
    Posts:
    25
    ...and how to move on a path of Vector3 values, with constant (chosen) speed, regardless of how many waypoints in the array...(the waypoints are at equal distance from eachother)
     
  30. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    @cranecam Hello. To rotate a RectTransform you just act on its transform:
    Code (csharp):
    1. myTransform.DORotate(new Vector3(0, 0, 180), 1);
    To move on a path with constant speed, you can either set the ease to Ease.Linear, or even use SetSpeedBased (always with a linear ease) to choose the units x second.

    Also note that the path system of DOTween doesn't require the waypoints to be at the same distance from each other in order to move at constant speed ;)
     
  31. oops64

    oops64

    Joined:
    Jul 2, 2015
    Posts:
    4
    hi Izitmee ,dose it supports something like : transform.RotateAround(Vector3 point, Vector3 axis, float angle) ?
     
  32. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    Hi @oops64 ,

    Sorry but no: no RotateAround for now (though I have it in my todo list for the future).

    EDIT: But you can always place your tweened target inside a parent, displace it, then rotate the parent, to achieve a RotateAround effect
     
  33. slimshader

    slimshader

    Joined:
    Jun 11, 2013
    Posts:
    187
    Thanks for the reply, moved to github enhancement request thread
     
  34. oops64

    oops64

    Joined:
    Jul 2, 2015
    Posts:
    4
    Thx for reply
     
  35. SidarVasco

    SidarVasco

    Joined:
    Feb 9, 2015
    Posts:
    163

    " The topic or board you are looking for appears to be either missing or off limits to you."

    I can't see which version you're referring too.

    Edit :

    I updated DTPro but now non of my tweens work =[
     
    Last edited: Jul 3, 2015
  36. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    @SidarVasco Ouch! Sorry for that: I suppose you had a pretty old version? You can see the upgrade instructions here.

    P.S. that page is inaccessible (as the download link I sent you before) if you're not registered on DOTween's private area (sorry again: I seemed to remember you were already registered, but I must've been wrong). Follow these instructions to do that.
     
  37. josessito

    josessito

    Joined:
    Feb 14, 2014
    Posts:
    57
    First of all, this is a fantastic asset, thanks a lot for it. Can I make a suggestion? This is probable not feasible but if it is a DOFloat DOInt shortcut would be great! I realize there may be some issues with it and that is way those are not included, but just in case there is a way, those to would be very helpful.

    Cheers and thanks again!
     
  38. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    Hi @josessito :)

    Sadly no, I would've done DOFloat and DOInt since a long time if I could, but it's not doable, because a custom float/int variable is different from a known Unity property (with which I can create DO extensions). But you now you can still tween a float like this, right?
    Code (csharp):
    1. DOTween.To(()=>myFloat, x=> myFloat = x, 32.5f, 2);
    Cheers!
     
  39. josessito

    josessito

    Joined:
    Feb 14, 2014
    Posts:
    57
    Hi Izitmee, yes I know that, thanks! I just meant a shortcut, but yes, it was wishful thinking, I knew there had to be some limitations for this not to be included (and it was just pure laziness from my part to have a shortcut :)). .
    Again, thanks for this fantastic asset!!
     
  40. SidarVasco

    SidarVasco

    Joined:
    Feb 9, 2015
    Posts:
    163

    Currently not at home but i update DOTween regurly. Ill try and do a clean install. It works fine with code though. Its just the components in the inspector have no effect.
     
  41. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    @SidarVasco Those upgrade instructions are related to DOTween Pro and the inspector components indeed. No need to do a clean install otherwise (and by the way, you don't need to update both DOTween and DOTween Pro: the Pro version also contains the basic one).
     
  42. SidarVasco

    SidarVasco

    Joined:
    Feb 9, 2015
    Posts:
    163
    Alright thanks. I only update pro anyways dont have both. But ill get back to you tomorrow and let you know


     
  43. SidarVasco

    SidarVasco

    Joined:
    Feb 9, 2015
    Posts:
    163
    Alright so my problem was that Auto Kill was active which caused my tween not to play, so that's fixed. Is there a way to automatically reverse a tween? Like a counter popping up from the top screen tweening in and after 2 seconds goes back up.
     
    Last edited: Jul 6, 2015
  44. cranecam

    cranecam

    Joined:
    Nov 25, 2013
    Posts:
    25
    hello,
    how do I kill an ongoing path tween when it collides with a 2d collider, and I directly want to use GotoWaypoint after collision occured.(i.e not complete the first path tween, but just "turn around" and go back some waypoints)
     
  45. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    @SidarVasco Just use a Yoyo loop with a 2 seconds tween.

    @cranecam Not sure I understood the question, but here it goes. To kill a tween, just use myTween.Kill(), to "turn it around" use myTween.Flip() or myTween.PlayBackwards().
     
  46. SidarVasco

    SidarVasco

    Joined:
    Feb 9, 2015
    Posts:
    163
    That doesn't work. I need it to pop in. Wait and then go back again.
     
  47. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    @SidarVasco ooops sorry, you're right. Then use a Sequence: append pop-in tween, append interval, append pop-out tween.
     
  48. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    NEW DOTWEEN UPDATE 1.0.800
    • NEW: SetRelative now works with Sequences too (sets all nested tweens as relative)
    • NEW: Added tween.Loops() method
    • Stack trace is now correctly shown in case of callback errors captured by an active safe mode
    • BUGFIX: Optimized DOJump so it now works with SetDelay and OnUpdate callbacks
    • BUGFIX: Fixed DOJump not ending correctly in case of single loops
    • BUGFIX: Fixed DOJump not working with SetRelative
    • BUGFIX: Fixed LoopType.Incremental not working with paths
     
  49. zhuchun

    zhuchun

    Joined:
    Aug 11, 2012
    Posts:
    433
    Hi, I'm trying to use DOTween to drive bullets, but DOTween seems only take duration to estimate the speed. Is that possible to use a constant velocity instead of it? Thanks.

    Code (CSharp):
    1. //Get a bullet from pool
    2. Transform _bullet= PoolManager.Pools[pool].Spawn(prefab);
    3. //Shoot to target transform
    4. _bullet.DOMove(target.position,1f);
    5. //use velocity instead of duration?
     
  50. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    Hi,

    You can use SetSpeedBased to make your duration become a speed indicator (and remember to set the ease to Linear if you want fully constant speed).
     
    zhuchun likes this.