Search Unity

DOTween (HOTween v2), a Unity tween engine

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

  1. kurasu1415

    kurasu1415

    Joined:
    Jan 27, 2015
    Posts:
    6
    Does anyone know if there is a way to get the Velocity of a tween? I need to know the distance and direction of a tweened transform in the current frame.
     
  2. Arkade

    Arkade

    Joined:
    Oct 11, 2012
    Posts:
    655
    I'd say it's unlikely but why not keep the last position and then calculate (change of (delta) position / Time.deltaTime each frame)?
     
  3. Kellyrayj

    Kellyrayj

    Joined:
    Aug 29, 2011
    Posts:
    936
    Is there an OnSomething event related to rewinding a tween so one could know when the rewind is finished?
     
  4. Arkade

    Arkade

    Joined:
    Oct 11, 2012
    Posts:
    655
    (For the forum's benefit @Izitmee kindly fixed this bug and pushed an update (Twitter pinged).)

    I now have a similar bug for fading when the game starts.
    • Expected behaviour is that the screen fades smoothly from black.
    • Observed behaviour in my enormous project is instantly clear (maybe 1 frame of semi-transparent black seen?).
    • Observed behaviour in the reproduction is that pausing produces similar behaviour but I haven't added enough code to the reproduction to get the same behaviour.

    I've attached this sub-par reproduction below.

    I've added some debug junk trying to figure out what's causing it. I suspect Unity is busy doing stuff and the timers aren't behaving as I'd expect meaning we get a stuttery fade rather than a smooth one. For example pausing Play Mode for a bit and then continuing causes the fade to jump. In my big project this means no fade. I suspect I'll have to kludge this by setting it not to use timeScale-insensitive tweening for that first fade ... or adding an initial pause so Unity/CLR can get its junk in order. Obviously I'm hoping you'll find a perfect fix and it'll all work without that :D

    Thanks
     

    Attached Files:

  5. pistoleta

    pistoleta

    Joined:
    Sep 14, 2017
    Posts:
    539
    Hi there!
    Im using DoTween on a city tycoon game, I use it for UI and sometimes for some effects with some gameObjects. When this objects are a lot (when a city is big) I get this warning:

    Max Tweens reached: capacity has automatically been increased from 200/50 to 500/50. Use DOTween.SetTweensCapacity to set it manually at startup.

    It's not an exception just a warning, and the game seems to be running just fine. Is this something I should worry about?

    Also when I move around and new objects with dotween functions in their scripts are spawned and destroyed I get this warning:

    Tween startup failed (NULL target/property - ): the tween will now be killed ► The object of type 'Transform' has been destroyed but you are still trying to access it.
    Your script should either check if it is null or you should not destroy the object.

    The problem here seems to be the Tween is still trying to access the transform after I Destroy it, so I tried to call
    transform.DoKill() to kill the tweens the object has before destroying but still getting it, any ideas why?

    Thanks!
    pistoleta
     
  6. netpost

    netpost

    Joined:
    May 6, 2018
    Posts:
    388
    Hi,

    Dotween Pro is a great little asset. I am just wondering how it integrate with unity timeline? For example if I do a text fade, It work from the top when hitting play but how can I fade a text that is 2min later in the timeline. I can easily activate the text with an activation track but then my fade doesn't work anymore. Any help would be appreciated. Thank you!
     
  7. pistoleta

    pistoleta

    Joined:
    Sep 14, 2017
    Posts:
    539
    Why dont you create a coroutine calling the tween? or an Invoke function with 2min delay? Is that what you want?
     
  8. netpost

    netpost

    Joined:
    May 6, 2018
    Posts:
    388
    Thank you for the quick reply. I forgot to mention I am not a programmer. I can add a delay directly in the dotween pro component for the fade but then I loose the main feature of the timeline which is flexibily. For example if the fade could happen only when the canvas containing the text is made active with the timeline canvas activation track, then I can ajust when the fade happen just moving slipping the small "activate clip" as I do all the time. I tried with the dotween manager choosing to play the fade when the object is active but I could not make it work.
     
  9. pistoleta

    pistoleta

    Joined:
    Sep 14, 2017
    Posts:
    539
    I'm not sure what you mean with the timeline, but on the example you set... If you want to do the fade when the canvas is made active you just have to subscribe to the event OnEnable. So you would add a little script that adds from MonoBehaviour to this canvas or to the child that has the TextComponent with this method:

    Code (CSharp):
    1. public Text myText;   <--- reference to your text component
    2.  
    3. //this triggers when the gameObject gets enabled
    4. private void OnEnable()
    5. {
    6.     myText.DoFade(......)
    7. }
     
  10. netpost

    netpost

    Joined:
    May 6, 2018
    Posts:
    388
    @pistoleta

    Thanks again for the quick reply. It is appreciated! Unfortunately, I have zero programming knowledge so I was planning to do it within the Dotween pro animation component. I am not in front of my computer at the moment but I remember seeing the onenable option in the dotween manager section of the dotween animation component. I couldn't make it work thought. I will try it again on Monday.

    Thanks again.
     
  11. netpost

    netpost

    Joined:
    May 6, 2018
    Posts:
    388
    @pistoleta

    I just came back from my computer work. You were right. Setting the "On active" option in the Dotween manager did the work. The mistake I did was to activate the canvas instead of activating the text itself. Once set up properly it worked really well.

    Thanks again pistoleta.
     
    pistoleta likes this.
  12. KarlKarl2000

    KarlKarl2000

    Joined:
    Jan 25, 2016
    Posts:
    606
    Hi guys,

    Does anyone know why this dotween starts fast and slows down near the end?
    Code (CSharp):
    1. _rectT.DOAnchorPosY(_endPosV2.y, 20, true).SetEase(Ease.Linear);
    Anyone have suggestions on how to get a linear interpolation speed? I tried using an animation curve, but it doesn't work either. :oops:
     
  13. pistoleta

    pistoleta

    Joined:
    Sep 14, 2017
    Posts:
    539
    Doesn't seem like anyone from DoTween is looking at this post at all for some time :confused:
     
    stobak and KarlKarl2000 like this.
  14. stobak

    stobak

    Joined:
    Dec 9, 2016
    Posts:
    16
    Hello!

    I'm trying to figure out how to get a game object to grow incrementally then togglepause once it's grown one step. Here's what I'm working with so far:


    Code (CSharp):
    1. transform.DOScale(new Vector3(2.5f, 2.5f, 2.5f), 1f)
    2.  
    3.             .SetLoops(-1, LoopType.Incremental)
    4.             .SetEase(Ease.OutBounce);
    5.             .OnComplete();
    From what I read in the documentation, I need to add a callback to the OnComplete paramater..problem is I'm not sure how to do that. Any tips would be appreciated!
     
  15. pistoleta

    pistoleta

    Joined:
    Sep 14, 2017
    Posts:
    539
    When you want to call something after the transition is complete you do it with the OnComplete method as you wrote... would be like this:

    Code (CSharp):
    1. transform.DOScale(new Vector3(2.5f, 2.5f, 2.5f), 1f)
    2.             .SetLoops(-1, LoopType.Incremental)
    3.             .SetEase(Ease.OutBounce);
    4.             .OnComplete( ()=>  CallYourMethod()  );
     
  16. TechHead

    TechHead

    Joined:
    Jan 23, 2017
    Posts:
    7
    Hi,

    I am using the 'DO Tween Transform Rotate' script on an object, rotating it via a central pivot point on the object, though when I go to rotate the object it doesn't complete a full 360 degree rotation, back to where is started. It is often off by about 10-30 degrees.

    There are no errors, etc.

    I have had a good look for any documentation on this particular rotation script, though I can't find anything explaining what all the other commands do.

    Any help or advice, much appreciated.

    Thanks in advance.
     
  17. stobak

    stobak

    Joined:
    Dec 9, 2016
    Posts:
    16
    Thank you! I made a bit of progress (new code below). The GrowBounce behavior works as expected the fist time. It grows larger with an ease OutBounce.. It only works once, however. Every time after that It will continue to grow in steps indefinitely. I want the growth the completely pause each time it's run a loop. Not sure what i'm doing wrong.

    Code (CSharp):
    1.     public GameObject player;
    2.  
    3.     public void PauseTween()
    4.     {
    5.         DOTween.TogglePause(player);
    6.     }
    7.  
    8.     void GrowBounce()
    9.     {
    10.         Tween myTween = transform.DOScale(new Vector3(2.5f, 2.5f, 2.5f), 1f);
    11.         myTween.SetAutoKill(true);
    12.         myTween.SetEase(Ease.OutBounce);
    13.         myTween.SetLoops(-1, LoopType.Incremental);
    14.         myTween.OnStepComplete(PauseTween);
    15.     }
    16.  
    17.     void GrowLarger()
    18.     {
    19.         GrowBounce();
    20.     }
     
  18. Azirell

    Azirell

    Joined:
    Oct 16, 2015
    Posts:
    29
    Hi everyone! My question probably has been answered already and still.
    Is the any way to do rewind tween without affecting tweened value?
    Example: I launch a tween and interrupt somewhere in the middle (with pause). And when I launch Rewind I want to just affect the tween itself, not tweened value.
     
  19. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,517
    For some reason creating tween and sequence generates a lot of GC...

    A simple tween such as below is generating 0.7k

    Code (CSharp):
    1. Profiler.BeginSample("Path Finder : Tween");
    2.         moveTween = tr.DOMove(halfPos, walkDuration * 0.5f).SetEase(Ease.OutCubic).OnComplete(OnMoveFirstStepComplete);
    3.         Profiler.EndSample();
    Also, I do set defaultrecycleable = true and it does indeed show in the dotween manager, but as soon as a tween is created and played, it becomes false.. But then the manager also shows that the tweens are being pooled?

    I can understand the initial allocation because they are being created first.. ( which we should avoid if possible and just use preallocated tweens ) but even if the manager seems to show the tweens are utilizing the pools, it still generates a lot of GC for some reason......

    I wonder if DoTween is still being supported by the Dev... I didn't see him here for a long time now...
     
    Last edited: Feb 7, 2020
  20. lordzeon

    lordzeon

    Joined:
    Jun 1, 2018
    Posts:
    44
    Hi, i want to thank for this amazing library, very easy to understand and use. I want to implement a path following with a manual Percent of it, i don´t want it to be updated based on time so i setup it like this:

    gameObject.transform.DOLocalPath(pathPoints.ToArray(), 1, PathType.CatmullRom, PathMode.Full3D, 10, Color.blue).SetLookAt(0.02f).SetLoops(-1, LoopType.Yoyo).SetUpdate(UpdateType.Manual);


    and then, when i need i call
    DOTween.ManualUpdate(currentProgress, currentProgress);


    currentProgress is a value between 0.0 and 1.0 . It doesn´t matter what value i use in unscaledDeltaTime, i always get the same result, the animation start when currentProgress is different from 0 at a very high speed and with each iteration is faster... i know im doing something wrong, but i didn´t find any example of use for ManualUpdate, someone could help me with this?
     
  21. mgnz

    mgnz

    Joined:
    Apr 2, 2016
    Posts:
    6
    Is there a way to tween Color to another color? Or use a tween on material with a custom property passed as a string argument?
     
  22. pistoleta

    pistoleta

    Joined:
    Sep 14, 2017
    Posts:
    539
    support dead
     
  23. FuguFirecracker

    FuguFirecracker

    Joined:
    Sep 20, 2011
    Posts:
    419
    Is support dead ? Maybe I'll start answering questions again ;)
    Hit me with your unanswered Qs, folks ... I'll see if I can help
     
  24. pistoleta

    pistoleta

    Joined:
    Sep 14, 2017
    Posts:
    539
    Aha! my bait worked :D
     
  25. pistoleta

    pistoleta

    Joined:
    Sep 14, 2017
    Posts:
    539
    My question:

    Hi there!
    Im using DoTween on a city tycoon game, I use it for UI and sometimes for some effects with some gameObjects. When this objects are a lot (when a city is big) I get this warning:

    Max Tweens reached: capacity has automatically been increased from 200/50 to 500/50. Use DOTween.SetTweensCapacity to set it manually at startup.

    It's not an exception just a warning, and the game seems to be running just fine. Is this something I should worry about?

    Also when I move around and new objects with dotween functions in their scripts are spawned and destroyed I get this warning:

    Tween startup failed (NULL target/property - ): the tween will now be killed ► The object of type 'Transform' has been destroyed but you are still trying to access it.
    Your script should either check if it is null or you should not destroy the object.


    The problem here seems to be the Tween is still trying to access the transform after I Destroy it, so I tried to call
    transform.DoKill() to kill the tweens the object has before destroying but still getting it, any ideas why?

    Thanks!
    pistoleta
     
  26. FuguFirecracker

    FuguFirecracker

    Joined:
    Sep 20, 2011
    Posts:
    419
    Is that a fish pun ? ;P
     
  27. FuguFirecracker

    FuguFirecracker

    Joined:
    Sep 20, 2011
    Posts:
    419
    No. If you game runs fine, it's fine. If you notice a hiccup, do what the warning compels you to do.
    Basically what is happening is that an extra block of memory is being reserved for new tweens.
    DOTween is just lettin' you know.

    If that a warning or a show stopping error? If warning, not anything to worry about if you are operating DOTween in "Safe Mode" ; On by default in the "Preference Panel".

    If it is an error -or it worries you so- you once again, do what the warning tells you. Check for null.

    Granted null checks are considered, by some, to be a code "smell". It's beyond my resource to tell you what to do about that ... Avoiding Null Checks
     
  28. pistoleta

    pistoleta

    Joined:
    Sep 14, 2017
    Posts:
    539
    lol, not intentionally, I just realized the fugu picture, but makes more sense :D:D

    Okay, it's just warnings so then nothing to worry about. But I found strange that after killing the tween before destroying the game objects I was still getting them. Thanks for your attention, I just needed to know if it this was something to be concerned since we are releasing soon.

    Thanks a lot,
    pistoleta
     
    FuguFirecracker likes this.
  29. Schizoid2k

    Schizoid2k

    Joined:
    May 6, 2015
    Posts:
    40
    I recently had this happen to me too. I was creating and running a Tween inside a method I was calling frequently. I am not sure what is going on in the back end, but it looks like tweens are stored and not removed unless they are deleted via Kill()... just guessing, of course.

    My solution was to create a class level Tween variable and not actually create the tween in the method. I no longer get those messages. I would look into that, since I would think that an increase to 500/50 means that something is hanging around.
     
  30. FuguFirecracker

    FuguFirecracker

    Joined:
    Sep 20, 2011
    Posts:
    419
    Hey @Schizoid2k ! Thanks for taking the time to reply and getting involved.
    I am! DOTween utilizes highly efficient methodologies to pool and recycle one's tweens. If one does not make use of these methods explicitly, DOTween will manage the pooling for you. Could one possibly do it better all by one's self? Possibly, but I think not. Not if you're seeing that message. :p

    Do not think of that debug message about increasing the tween pool as anything severe. It is not.

    This leads me to believe that you were unnecessarily creating redundant tweens in an update loop when a singular tween did suffice.

    Something is hanging around; The tween pool. This is known, required, and desired. Pools are good.

    And there's the expanded explanation on my previous explanation.
    Let me know if you have any Questions.

    #edit
    I hadn't considered that @pistoleta might be doing the same and generating an inordinate amount of tweens due to continuous creation in an update loop... I had given them the benefit of the doubt because they had said it was due to an abundance of gameObjects.... But you are very much correct. This message could indicate that one is creating a whole bunch of useless tweens every frame. This is a common newb mistake. I did not take @pistoleta for a newb ;)
     
    Last edited: Feb 23, 2020
  31. Schizoid2k

    Schizoid2k

    Joined:
    May 6, 2015
    Posts:
    40
    @FuguFirecracker

    Thanks for the information. I did assume I was creating useless tweens, but I was not sure why. I was creating my tweens in a method (not Update) that was called after the user pressed a button. I am creating a word game, so when the user selected some letters and submitted the word, a few tweens were created and run.

    After noticing that message, I added a debug of PlayingTweens() and PausedTweens() and noticed they were just increasing, even after the tweens completed.

    I *assumed* it was something I was doing incorrectly, but my new solution removes that message.

    Thanks! :)
     
  32. Aurigan

    Aurigan

    Joined:
    Jun 30, 2013
    Posts:
    291
    Hit a bug in using the Preview Mode - think I removed a DOTweenAnimation component while the play all button was toggled on. This triggers an error:

    ArgumentNullException: Value cannot be null.
    Parameter name: target
    DG.DOTweenEditor.DOTweenPreviewManager.StopPreview (System.Collections.Generic.List`1[T] keys) (at Assets/3rd Party/Demigiant/DOTweenPro/Editor/DOTweenPreviewManager.cs:218)
    DG.DOTweenEditor.DOTweenPreviewManager.StopAllPreviews () (at Assets/3rd Party/Demigiant/DOTweenPro/Editor/DOTweenPreviewManager.cs:124)
    DG.DOTweenEditor.DOTweenAnimationInspector.OnDisable () (at Assets/3rd Party/Demigiant/DOTweenPro/Editor/DOTweenAnimationInspector.cs:205)

    And then breaks preview working, even after restarting Unity. Somehow after this throwing a ton of errors, warnings, not working, creating loads of empty game object ... it resolved itself :)

    1.0.178 DOTween Pro, Unity 2019.3.0f6
     
  33. cadxplore

    cadxplore

    Joined:
    Sep 4, 2019
    Posts:
    17
    Does anyone use AnimationCurve on SetEase?
    I'm trying to create an "overshoot" behavior by using my own custom AnimationCurve but it doesn't seem to be working correctly. The movement always clamps at 1 and can't go beyond that. I've tried changing the animation curve setting to Ping Pong/Loop, neither of them works.

    Is this a bug or I misused animation curve or DOPath doesn't work with custom animation curve?

    Here's the code snippet
    Code (CSharp):
    1. coin.transform.DOPath(new Vector3[] {coin.transform.position, bounceTo, midPoint, destination }, duration, PathType.CatmullRom)
    2. .SetEase(m_coinAnimationCurve);
    Below is the animation curve that I'm using.
    Screenshot 2020-03-13 at 10.37.23 AM.png
     
    Last edited: Mar 13, 2020
  34. mrsimmo

    mrsimmo

    Joined:
    May 4, 2013
    Posts:
    12
    Hi there,

    With apologies - I think this is a stupidly basic question but I can't figure it out.
    I'm trying to fade out some text, change it to the new string, then fade it back in again.

    I *thought* I could call the update function from a call back after the fadeout, but clearly that's not right. Do I need to use a coroutine to do this?



    Code (CSharp):
    1. void UpdateUI(string textNew, string nameNew, string bgName){
    2.  
    3.  
    4.     Sequence mySequence = DOTween.Sequence();
    5.     mySequence.Pause();
    6.     mySequence.Append(nameText.DOFade(0,1));
    7.     mySequence.Append(mainText.DOFade(0,1).OnStepComplete(updateWords(textNew, nameNew)));
    8.     mySequence.Append(mainText.DOFade(1,1));
    9.     mySequence.Append(nameText.DOFade(1,1));
    10.     mySequence.Play();
    11.  
    12. }
    13.  
    14. TweenCallback updateWords(string textNew, string nameNew){
    15.     mainText.text = textNew;
    16.      nameText.text = nameNew;
    17.      return null;
    18. }
     
  35. FuguFirecracker

    FuguFirecracker

    Joined:
    Sep 20, 2011
    Posts:
    419
    H!
    You do not need a coroutine. DoTween uses it's own internal coroutines.
    Naming your methods with 'update' is a bad idea. Makes me think that you're calling tweens from Unity's Update Magic Method... If you are doing that... don't do that!

    Here ya go:

    Code (CSharp):
    1. private void FadeUIText(Text uiText, string newTextValue = "" ) // <= that's an OPTIONAL parameter
    2.         {
    3.             if (newTextValue == string.Empty) { newTextValue = uiText.text; }
    4.          
    5.             uiText.DOFade(0, 1).OnComplete(() =>
    6.                 {
    7.                     uiText.text = newTextValue;
    8.                     uiText.DOFade(1, 1);
    9.                 }
    10.             );
    11.         }
    and you'd call it as such :

    Code (CSharp):
    1.   FadeUIText(MyText, "Pudding");
    2.   FadeUIText(MyOtherText);
     
  36. mrsimmo

    mrsimmo

    Joined:
    May 4, 2013
    Posts:
    12
    Thanks so much for this, that works great - hugely appreciated!

    I wasn't using any tween calls from within Update, but have changed all those method names now on your advice! :)




     
    FuguFirecracker likes this.
  37. robal1991

    robal1991

    Joined:
    Mar 31, 2016
    Posts:
    33
    Hello, I have a problem with tweening my notifications system in my project.
    I can have multiple notifications displayed at once. They are in a vertical layout group in notifications container. The newest notification is on the bottom. Notifications can have different heights. Notifications last 2 or 5 seconds. I want a simple IN animation from the bottom of the screen.

    My current code is:
    Code (CSharp):
    1. GetComponent<RectTransform>().DOAnchorPosY(-150f, 0.5f).From().SetEase(Ease.OutBack);
    -150 as starting Y value should be enough.

    Everything works fine when there is only 1 notification. But when I spawn multiple notifications the Y positions get messed up and notifications are overlaying each other. Somehow the layout group script and DOTween animations are not working properly together. Please help me what is the proper way of solving this problem.

    I'm attaching example project, where you can spawn notifications with keyboard and see better what is the problem.

    Thanks for help.
     

    Attached Files:

  38. FuguFirecracker

    FuguFirecracker

    Joined:
    Sep 20, 2011
    Posts:
    419
    Stop screwing around with the anchor positions and use DOLocalMoveY instead.
    You should see a marked improvement in the execution.

    You're gonna have a bad time fighting against that VerticalLayoutGroup that wants to put your gameobjects where it wants to put them. Bluntly, you shouldn't be doing what you're doing.

    If you are dead-set on using the VerticalLayoutGroup, it is advisable that you send your next notification only after the previous notification has reached the culminate of it's transfom.position.
     
  39. robal1991

    robal1991

    Joined:
    Mar 31, 2016
    Posts:
    33
    Thanks for help! I managed to solve my problem:
    • using DOLocalMoveY instead of DOAnchorPosY
    • packed all elements into another gameobject named "Content". "Content" is now animated by DOTween and the root of the prefab is positioned by vertical layout group
    • moved animation start to an Coroutine with one-frame delay so that vertical layout group can update it's content
     
  40. Froghuto

    Froghuto

    Joined:
    Oct 4, 2012
    Posts:
    61
    Using the latest DOTween asset store version and Unity 2019.3.5f and with disabled "Reload Domain" and "Reload Scene" options (under "Enter Play Mode Options (Experimental)) it sometimes (randomly) happens that DOTween does not "execute" any tweens. They will get started, but will never actually "run". Also the "[DOTween]" Gameobject that gets automatically created will not get moved to the "DestroyOnLoad" Scene but will stay in the normal active Scene - and will also show the running tweens just piling up.
    Is this something anyone has experienced before, or does anyone know a sulution?
     
  41. EarthHobbit

    EarthHobbit

    Joined:
    May 10, 2016
    Posts:
    46
    Is there a way to have the moving objects following a terrain, rather than straight interpolated translation ?
     
  42. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    @Froghuto This didn't happen before. Could I ask you to post this as an issue here with as many details as possible so I can try to replicate it? Cheers :)
     
    Froghuto likes this.
  43. FuguFirecracker

    FuguFirecracker

    Joined:
    Sep 20, 2011
    Posts:
    419
    Like This?
    doTweeenTraveler.gif

    DOPath !

    However, DOPath will not generate a path for you. You need to generate that yourself.
    Hint: use raycasting.
     

    Attached Files:

  44. bali33

    bali33

    Joined:
    Aug 14, 2011
    Posts:
    232
    Hello,

    I'm prototyping a character behaviour which can basically jump and dash. Because there gonna be collisions I'd like to use physics to resolve them but I'd like to use DoTween for the jump and dash in order to have more control and a game-play that fits better what I have in mind.

    I thought to kill the jump/dash tweener when detecting a collider collision and then let the physics "resumes/resolves" the collision. But Rigidbody2D.DOMove does not affect the velocity so right after killing the tweener the velocity is null and the collision will not produce the desired result.

    So what would you do ? Not use DOTween and manage everything using AddForce which can be tricky to set-up or use use DOTween and also manage/fake collision when a collision is detecting or ... Any idea ?

    Thanks
     
  45. FuguFirecracker

    FuguFirecracker

    Joined:
    Sep 20, 2011
    Posts:
    419
    Hello!
    I have no idea of your prototype nor gameplay, so I'm going to limit my response to a DOTween-centric implementation. ... Although I don't know if I would necessarily use DOTween to do what you're trying to do. De -do -do-do ...
    You're mistaking speed for velocity. You don't need to know the velocity of the moving RigidBody, you only need to know the how fast it was going when it collided the other collider. Speed and Velocity

    Speed = Distance / Time
    So if you know where you started, where you stopped, and how long it took to get there, you know how fast you were going.

    The second thing you want to know is the angle of incidence.
    I wouldn't use the angle of reflection to apply your force, rather, I'd AddForce() back towards the angle of incidence with a random variation of +|- 2 degrees depending on your implementation.

    So...
    Rigidbody is kinematic
    Begin Tween.
    Retain start position variable and time variable
    Collide with other
    Rigidbody is not kinematic
    Calculate the speed
    Calculate angle of incidence
    Add an amount of force in relation to the speed on the angle of incidence.
    Fall to your death
    Repeat.
     
  46. bali33

    bali33

    Joined:
    Aug 14, 2011
    Posts:
    232
    Ok,

    I know I can compute speed, angle and then apply a force but it means more works and maybe it is what I should do. But I was wondering if somehow I could switch from DOTween - "Unity physics" at any time and maybe someone knows.
    To be honest, I don't expect this to be possible, but sometimes good news happen ;-)

    Thanks !
     
  47. FuguFirecracker

    FuguFirecracker

    Joined:
    Sep 20, 2011
    Posts:
    419
    Unity Physics evaluates every RigidBody in the scene during every physics update tick.
    Excpet when your object is marked as "kinematic"; Unity preforms no calculations on that object.
    Therefore, Unity has no information about where your object was nor where it is going prior to being released back to the physics system. Consequently, it cannot extrapolate any meaningful calculations apart from where it appears at the point of being set to not kinematic.

    Moving your object outside of the physics system without it being set to kinematic is worse because it just serves to dirty the entirety of the physics calculations in the scene and unity also cannot perform any meaningful calculations on your rigidbody because unity physics system wasn't in control of that movement.

    There is no allowance to go back in time and do physics calculations on an object that you move outside of the system.

    Hope that clears that up for you.
     
  48. EarthHobbit

    EarthHobbit

    Joined:
    May 10, 2016
    Posts:
    46
    Yes like this thanks. So I need to manually setup the path and having dotween following it. Sad there is no way to attach a terrain to DOTween and having it following the terrain. But thanks !
     
    FuguFirecracker likes this.
  49. SlavomirDurej

    SlavomirDurej

    Joined:
    Oct 25, 2018
    Posts:
    32
    Is there a way to find out which tween / tween called by which class have caused an error like this?

    Code (CSharp):
    1. 16:44:20:663] MissingReferenceException: The object of type 'RectTransform' has been destroyed but you are still trying to access it.
    2. Your script should either check if it is null or you should not destroy the object.
    3. UnityEngine.Transform.set_localScale (UnityEngine.Vector3 value) <0x199c9200 + 0x0005a> in <0d555f4551ef4f4a858f0ae7c1078c2c>:0
    4. DG.Tweening.ShortcutExtensions+<>c__DisplayClass45_0.<DOScale>b__1 (UnityEngine.Vector3 x) (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__DOTween/_DOTween.Assembly/DOTween/ShortcutExtensions.cs:628)
    5. DG.Tweening.Plugins.Vector3Plugin.EvaluateAndApply (DG.Tweening.Plugins.Options.VectorOptions options, DG.Tweening.Tween t, System.Boolean isRelative, DG.Tweening.Core.DOGetter`1[T] getter, DG.Tweening.Core.DOSetter`1[T] setter, System.Single elapsed, UnityEngine.Vector3 startValue, UnityEngine.Vector3 changeValue, System.Single duration, System.Boolean usingInversePosition, DG.Tweening.Core.Enums.UpdateNotice updateNotice) (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__DOTween/_DOTween.Assembly/DOTween/Plugins/Vector3Plugin.cs:151)
    6. DG.Tweening.Core.TweenerCore`3[T1,T2,TPlugOptions].ApplyTween (System.Single prevPosition, System.Int32 prevCompletedLoops, System.Int32 newCompletedSteps, System.Boolean useInversePosition, DG.Tweening.Core.Enums.UpdateMode updateMode, DG.Tweening.Core.Enums.UpdateNotice updateNotice) (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__DOTween/_DOTween.Assembly/DOTween/Core/TweenerCore.cs:247)
    7. DG.Tweening.Tween.DoGoto (DG.Tweening.Tween t, System.Single toPosition, System.Int32 toCompletedLoops, DG.Tweening.Core.Enums.UpdateMode updateMode) (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__DOTween/_DOTween.Assembly/DOTween/Tween.cs:252)
    8. DG.Tweening.Core.TweenManager.Update (DG.Tweening.UpdateType updateType, System.Single deltaTime, System.Single independentTime) (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__DOTween/_DOTween.Assembly/DOTween/Core/TweenManager.cs:490)
    9. DG.Tweening.Core.DOTweenComponent.Update () (at D:/DG/_Develop/__UNITY3_CLASSES/_Holoville/__DOTween/_DOTween.Assembly/DOTween/Core/DOTweenComponent.cs:73)
    10.  
    this happens under unclear circumstances when a lot of things are happening on the screen so it's pretty difficult to just guess what is not being destroyed...
     
  50. bali33

    bali33

    Joined:
    Aug 14, 2011
    Posts:
    232
    Hello,

    I have a UI item that can be moved, shake, fade etc. Each time one of this operation occurred I store tween operation into a Sequence and at the beginning of each I killed the sequence to be sure that nothing else is modifying my item. I do so using something like :
    Code (CSharp):
    1. _currentSequence?.Kill();
    But doing this I got a lot of warning that the tween is no longer valid. I have the feeling that it is related to tweening recycle because the issue disappear when recycling is disabled. But I'd like to use recycling because I have to tween a lot of objects very fast at some point. So would be great to understand what is happening here.

    Thanks