Kill nested Sequence
« on: November 19, 2015, 10:59:42 AM »
Hi,

I'd like to use nested sequence but I need to be able to stop the nested sequence and can't reach this.

here's an example pseudo code :

Code: [Select]
    Sequence _sequence;
    Sequence _sequence1;

    public void Start()
    {
        _sequence = DOTween.Sequence();
        _sequence1 = DOTween.Sequence();

        _sequence1.AppendInterval(5f).OnComplete(() => Debug.Log("Completed"));

        _sequence.AppendCallback(() => Debug.Log("Do Some stuff"));
        _sequence.Append(_sequence1); // wait 5 seconds then log "Completed"
        _sequence.AppendCallback(() => Debug.Log("Do Some more stuff"));
    }
   
    void Update()
    {
        if(some_condition)
        {
                Debug.Log("Try to kill");
                _sequence1.Kill(true);
        }
    }

In the above code, consider that some_condition is, in my test case, true at some point of the execution of _sequence1, but _sequence1 never get killed...

How can I achieve that ? Is there something that I'm not aware about ?

Thanks in advance

*

Daniele

  • Dr. Admin, I presume
  • *****
  • 378
    • View Profile
    • Demigiant
Re: Kill nested Sequence
« Reply #1 on: November 19, 2015, 12:08:14 PM »
Hi!

Once you add a tween to a Sequence, the main Sequence is the only thing that can be controlled. Nested tweens cannot. Consider that a Sequence is like a movie timeline composed of other movies/tweens. Once you create the main Sequence, it's "rendered" and only that can be controlled.

Cheers,
Daniele

Re: Kill nested Sequence
« Reply #2 on: November 19, 2015, 12:17:19 PM »
Ok, that's what I thougth but I wanted to be sure not to miss something...

That's kind of a sad thing though  :'(

Do you plan in implementing this feature in the future ?

*

Daniele

  • Dr. Admin, I presume
  • *****
  • 378
    • View Profile
    • Demigiant
Re: Kill nested Sequence
« Reply #3 on: November 19, 2015, 12:23:00 PM »
I'm sorry but no, I don't plan to implement this. The reason is that a Sequence is strongly tied to its nested tweens, because, for example, one tween could animate a property in one way, while the next could animate the same property in another, and so the Sequence actually creates a kind of cache based on each internal animation and on the consequences it has on the other ones. Allowing to control nested tweens would completely break this approach and it would make a mess :P

Re: Kill nested Sequence
« Reply #4 on: November 19, 2015, 12:23:29 PM »
Well if that can help someone, I found a workaround for this precise case using Goto :

Code: [Select]
    Sequence _sequence;
    Sequence _sequence1;

    public void Start()
    {
        _sequence = DOTween.Sequence();
        _sequence1 = DOTween.Sequence();

        _sequence1.AppendInterval(5f).OnComplete(() => Debug.Log("Completed"));

        _sequence.AppendCallback(() => Debug.Log("Do Some stuff"));
        _sequence.Append(_sequence1); // wait 5 seconds then log "Completed"
        _sequence.AppendCallback(() => Debug.Log("Do Some more stuff"));
    }
   
    void Update()
    {
        if(some_condition)
        {
                Debug.Log("Try to goto");
                _sequence.Goto(4.99f, true);
        }
    }

If I put 5f instead of 4.99f, the last callback ( "Do some more stuff" ) is not executed.

Hope it can help.
« Last Edit: November 19, 2015, 12:25:16 PM by exkise »

Re: Kill nested Sequence
« Reply #5 on: November 19, 2015, 12:24:46 PM »
I'm sorry but no, I don't plan to implement this. The reason is that a Sequence is strongly tied to its nested tweens, because, for example, one tween could animate a property in one way, while the next could animate the same property in another, and so the Sequence actually creates a kind of cache based on each internal animation and on the consequences it has on the other ones. Allowing to control nested tweens would completely break this approach and it would make a mess :P

Alright, I understand. Thanks for your time and your great work !