Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Append to Already Playing Sequence #132

Open
ceyhuntasci opened this issue May 9, 2017 · 5 comments
Open

Append to Already Playing Sequence #132

ceyhuntasci opened this issue May 9, 2017 · 5 comments

Comments

@ceyhuntasci
Copy link

@ceyhuntasci ceyhuntasci commented May 9, 2017

My animation is basicly shows the valid words user found in order.

My method does this:

    if (showWordsSequence.IsPlaying())
    {
        showWordsSequence.Append(group.transform.DOScale(1f, 0.6f));
        showWordsSequence.AppendInterval(0.2f);
        showWordsSequence.Append(group.transform.DOScale(0f, 0.6f));
        showWordsSequence.Append(DOVirtual.DelayedCall(0.2f,() => Destroy(group.gameObject)));

    }
    else
    {
        showWordsSequence = DOTween.Sequence();
        showWordsSequence.Append(group.transform.DOScale(1f, 0.6f));
        showWordsSequence.AppendInterval(0.2f);
        showWordsSequence.Append(group.transform.DOScale(0f, 0.6f));
        showWordsSequence.Append(DOVirtual.DelayedCall(0.2f, () => Destroy(group.gameObject)));
    }

showWordsSequence is a global Sequence variable. When I call this method 3 times in a for loop (in the same frame) it works. But, when sequence starts playing and after 1-2 seconds, i call this method again it does not append the animation. Is there any workaround on this?

@Malhavok

This comment has been minimized.

Copy link

@Malhavok Malhavok commented May 10, 2017

Taken from documentation:
http://dotween.demigiant.com/documentation.php

  1. About appending sequences: Note that all these methods need to be applied before the Sequence starts (usually the next frame after you create it, unless it's paused), or they won't have any effect.
  2. About virtual methods (I'm impressed that these work): NOTE: virtual methods can't be placed inside Sequences.

Sadly, the only workaround I know is to create whole sequence beforehand. Other idea is to create second, paused, sequence, append to it and have OnComplete callback starting playback of the new one (if it ain't empty).

@ceyhuntasci

This comment has been minimized.

Copy link
Author

@ceyhuntasci ceyhuntasci commented May 10, 2017

Thanks for your reply!

Wish we could just append to ongoing sequences ^^ I had seen the thing about virtual methods but it always works for me i don't know why.

@Demigiant

This comment has been minimized.

Copy link
Owner

@Demigiant Demigiant commented May 12, 2017

I might actually rethink about appending to ongoing Sequences, but will take me a while.

Virtual methods do return a Tween object, so in theory they "can" be added to Sequences. But since they're somehow different, I don't recommend doing that. In short, I'm not taking any responsibility for virtual methods inside Sequences :D

@ceyhuntasci

This comment has been minimized.

Copy link
Author

@ceyhuntasci ceyhuntasci commented May 12, 2017

That would be so great actually.

Yes, you are right. I've rewritten the virtual methods, they are acting kinda funny. Thou shalt not trust virtual methods!!!

@EvgenL

This comment has been minimized.

Copy link

@EvgenL EvgenL commented Jan 23, 2019

Hi. In case anyone else is googling it in 2019. This is the best workaround for this situation.

//'Global' queue for animations. First one ( .Peek() ) is playing, others are waiting in queue
    public Queue<Sequence> AnimationQueue = new Queue<Sequence>();

    //Entry point
    public void PlayQueuedAnimation()
    {
        //Create paused sequence 
        var seq = DG.Tweening.DOTween.Sequence();
        seq.Pause();

        //Append everything you want
        seq.Append(targetTransform.DOLocalMoveX(5f, 1f));
        //...

        //Add to queue
        AnimationQueue.Enqueue(seq);

        //Check if this animation is first in queue
        if (AnimationQueue.Count == 1)
        {
            AnimationQueue.Peek().Play();
        }

        //Set callback 
        seq.OnComplete(OnComplete);
    }

    //Callback
    private void OnComplete()
    {
        //remove animation that was completed
        AnimationQueue.Dequeue();

        //if there's animations in queue left
        if (AnimationQueue.Count > 0)
        {
            //play next
            AnimationQueue.Peek().Play();
        }
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.