-
-
Notifications
You must be signed in to change notification settings - Fork 66
Description
Hey :)
I am often "composing" multiple sequences into each other, where I have one big sequence into which I chain/group lots of other sequences. I often get to the point where I want to start two sequences at once (i.e. group), but one of them should start with some delay. I could do this with an insert, but for that i'd need the current duration of the sequence and computing this delay through adding up the durations of all other chained sequences seems combersome and not maintainable.
My current solution is to chain a delay to the start of the sequence I want to group. It doesn't feel very clean though and is not that easy to work with:
private void CreateBigSequence()
{
Sequence bigSequence = Sequence.Create();
bigSequence.Chain(_firstSequence);
bigSequence.Group(_secondSequence);
bigSequence.Group(GetMyThirdSequence(0.1f)); // third sequence should start playing 0.1 seconds after first sequence
}
private Sequence GetMyThirdSequence(float delay)
{
Sequence thirdSequence = CreateDelayedSequence(delay);
thirdSequence.Chain(...);
return thirdSequence;
}
public Sequence CreateDelayedSequence(float startDelay)
{
Sequence sequence = Sequence.Create();
if (startDelay > 0f)
sequence.ChainDelay(startDelay);
return sequence;
}Doing that with inserts instead is even more complicated, since I can't switch _secondSequence and the third sequence, because then _secondSequence couldn't be grouped with first anymore (also it's odd to read, since practically the second sequence starts before the third).
What would be cool:
private void CreateBigSequence()
{
Sequence bigSequence = Sequence.Create();
bigSequence.Chain(_firstSequence);
bigSequence.Group(_secondSequence);
bigSequence.Group(GetMyThirdSequence(), delay: 0.1f);
}