Tween got killed without obvious reason
« on: November 24, 2015, 11:44:26 AM »
Hi, i got strange behavior of tween in my project.
Sometimes it's playing normally without problems. But sometimes it's got killed at the beginning or in the middle of tween.

Code: [Select]
_playerMapObject.DOLocalMove(targetPosition, playerMoveTime)
                                .OnStart(() =>
                                {
                                    Debug.Log("move started");
                                })
                                .OnPause(() =>
                                {
                                    Debug.Log("move paused");
                                })
                                .OnUpdate(() =>
                                {
                                    Debug.Log("move update, position: " + _playerMapObject.localPosition);
                                })
                                .OnKill(() =>
                                {
                                    Debug.Log("move killed");
                                })
                                .OnComplete(() =>
                                {
                                    if (needToPrestartNextLevel)
                                    {
                                        needToPrestartNextLevel = false;
                                        gpm.OpenLevel(curLevel);
                                    }
                                    Debug.Log("move complete");
                                });

_playerMapObject is Transform of GameObject, that contains child GameObject with 2dToolkit image attached
_playerMapObect.localPosition NEVER equals to targetPosition before tween call.
playerMoveTime always equals 0.5f

I tried to use SetAutoKill(true/false) on current tween and also set autoKill to true/false in DoTween Settings Panel. Anyway it can play fully or get killed after one or two OnUpdate calls or even just after OnStart call. Also i tried to set true/false on reuse tweens - same results.

I never use Kill for tweens so i think it's killed by DoTweenManager.

I'm using Unity 5.2.1f1 on Windows. Target platform Standalone. Used DoTween version 1.0.750. Update to version 1.1.060 changed nothing....

Please help me, project near release date, so i need to fast fix it.

*

Daniele

  • Dr. Admin, I presume
  • *****
  • 378
    • View Profile
    • Demigiant
Re: Tween got killed without obvious reason
« Reply #1 on: November 24, 2015, 11:49:43 AM »
Hi!

I just replied to your mail. Let me know here if what I wrote helps. As a note, I think I can confirm 100% that there is no auto-kill bug (I would've noticed a long time ago), so there must be some reason in your code for his behaviour.

Cheers,
Daniele

Re: Tween got killed without obvious reason
« Reply #2 on: November 24, 2015, 12:01:43 PM »
Text from your mail:
Quote
Tweens being killed without reason seems very strange. I use DOTween a lot and never encountered this bug (nor anyone else has). I think the possible reasons in your case might be:
  • The tween's target becomes NULL, and thus the tween suicides to prevent errors
  • You're trying to restart a tween that is already complete and has SetAutoKill to FALSE, and thus has already being killed
  • You're firing another tween on the same property, and thus the two will fight each other and only one will win
  • You have some other forces blocking the tween
  • You are calling myTarget.DOKill, which will kill all tweens on that same target

1. Tweens target is GameObject instantiated at Start() function of my MonoBehavior-inherited script. Script attached to GameObject in Scene. Instantiate using preconfigured Prefab. After that - tween is only action that i doing with that object.
2. Tween got new created every time when i need to move _playerMapObject. Never tried to restart it.
3. Haven't other tweens using _playerMapObject as target.
4. No idea...
5. Never calling DOKill

Re: Tween got killed without obvious reason
« Reply #3 on: November 24, 2015, 12:17:15 PM »
I made back up to my project GIT stable version. DoTween version again 1.0.750.
Same issue happening sometimes. BUT!!! After i unchecked "Recycle Tweens" in settings panel bug disappeared and tweens started to work like a charm ;D
I will try update to latest version of DoTween now and update post with results of check/uncheck recycle.

*

Daniele

  • Dr. Admin, I presume
  • *****
  • 378
    • View Profile
    • Demigiant
Re: Tween got killed without obvious reason
« Reply #4 on: November 24, 2015, 12:18:39 PM »
When is the auto-kill happening? After loading a level (which I suppose is what you do with gpm.OpenLevel)? Let me know as much detail as possible.

Also, grab this DOTween update (unzip it as usual then re-run the setup). It has an improved DOTween Inspector, so that, if you select the DOTween gameObject during runtime, you have additional buttons to show info on exactly which tweens are running/paused. That might help you understand more of what's happening.

*

Daniele

  • Dr. Admin, I presume
  • *****
  • 378
    • View Profile
    • Demigiant
Re: Tween got killed without obvious reason
« Reply #5 on: November 24, 2015, 12:20:08 PM »
Oh, just saw your new reply. Great that it works now :) And interesting. Recycling can cause issues if not used correctly, but in your case you're not storing the tween's reference so it shouldn't be a problem. Let me know what else you discover.

Re: Tween got killed without obvious reason
« Reply #6 on: November 24, 2015, 12:28:04 PM »
Just added version you attached. Without recycling it's working as expected, but when i'm turning it ON. Bug appears again. Now AutoKill in settings panel is true state.
I'm using DoTween in whole project. For moving GameObjects that contains NGUI or 2dToolkit components attached. Changing color, alpha, rotation and scale. DoTween really saved my life  :)

What do you mean by
Quote
Recycling can cause issues if not used correctly
???
I moving playerObject on map by tween from one level button to another. After that many tweens used in gameplay. After level Win - new move animation runned - to go to the next level button. I think recycling broken self or by my code  ;)

*

Daniele

  • Dr. Admin, I presume
  • *****
  • 378
    • View Profile
    • Demigiant
Re: Tween got killed without obvious reason
« Reply #7 on: November 24, 2015, 12:40:11 PM »
Whew :) And by the way, recycling is really not necessary (I personally don't use it) considering how lightweight DOTween is, and that the bulk of every tween (which is the animation system) is always recycled even if recycling is off.

About the issues that can happen if recycling is not used with care, you can read more here. In short, you might end up with tween references that are actually referencing a different tween, and thus controlling/killing/etc the wrong one. On this matter, let me know if you were using references at all in your project, because if not, there might indeed be a bug with recycling and I'll need to check it out.

Re: Tween got killed without obvious reason
« Reply #8 on: November 24, 2015, 12:51:53 PM »
Yeah, i have few references to Tweens in project. Just noticed that with recycling turned on, _playerMapObject move tween becomes gameplay main sequence used to animate all game elements. Only tween killed manually in project is.... ta-da! gameplay main sequence))) So it can be reason of buggy appearance and unexpected killing of tween.

But! I'm using gpMainSequence.SetOnComplete() for some animation logic of gameplay. With recycling turned ON it seems like SetOnComplete working like "+=" instead if "=" so my gameplay animation logic works like expected but in the same time i got Debug.Log() messages, used for test _playerMapObject move tween. So i mean recycling doesn't fully clean Tween for reuse.

*

Daniele

  • Dr. Admin, I presume
  • *****
  • 378
    • View Profile
    • Demigiant
Re: Tween got killed without obvious reason
« Reply #9 on: November 25, 2015, 11:07:26 AM »
That is weird about SetOnComplete. The way DOTween's callbacks are built, they don't support += at all. Also, I just checked to be sure, and OnComplete is indeed reset to NULL when recycling a tween. I'll investigate more.

Re: Tween got killed without obvious reason
« Reply #10 on: January 15, 2016, 03:54:19 PM »
Hi.

+1 to this problem but in my case, even with recycle tweens disabled, i have the "bug". I checked the 5 points mentioned before and none of them relate. Is there any other way to debug this situation?

I'm using unity 5.3.1p1 and dotween v1.1.135

How it happens -
I have a disabled gameobject with a script. I call a function on that script that enables the gameObject and plays the animation. The animated object is a child of the previous mentioned object.
Sometimes it works but most of the times it kills the animation before it finishes. The animation is killed at random points.

Code: [Select]
public override void Open()
{
gameObject.SetActive(true);
m_panelTransform.anchoredPosition -= Vector2.up * 450;
m_panelTransform.DOAnchorPos(Vector2.zero, 1.5f).SetEase(Ease.OutExpo).SetAutoKill(false).OnKill(OnKill);
}

void OnKill()
{
Debug.Log("Killed");
}

*

Daniele

  • Dr. Admin, I presume
  • *****
  • 378
    • View Profile
    • Demigiant
Re: Tween got killed without obvious reason
« Reply #11 on: January 15, 2016, 04:48:03 PM »
Hi,

I often use your same logic (enable child and run tween from parent) and never encountered this issue. Can you write me the full log you get when "Killed" is logged? That might help find the issue.

Cheers,
Daniele

Re: Tween got killed without obvious reason
« Reply #12 on: January 17, 2016, 06:01:10 PM »
Wow, i feel like a noob now. Totally forgot to check the full log and it seems that, for some reason, I had a DoTween.Clear(); lost in my code.

Sorry for the inconvenience and thank's for the awesome plugin that is DoTween :)

*

Daniele

  • Dr. Admin, I presume
  • *****
  • 378
    • View Profile
    • Demigiant
Re: Tween got killed without obvious reason
« Reply #13 on: January 17, 2016, 06:19:54 PM »
Ah, glad it's solved, and thanks for the DOTween appreciation :)