0
Answered

Sequence behaviour from 1.3 instead of 1.4

BearHugMark 11 months ago • updated by Lazlo Bonin (Lead Developer) 3 days ago 14

Hi Bolt peoples!

Sequence used to trigger the flow one item after the other, but now it appears to wait for flow 0 to finish before moving on to flow 1 etc. 

Unfortunately this completely breaks my meta-game logic.

Is there a way to get the old 1.3 behaviour back? I basically need Chapter1 and Tutorial_ChestUnlock to run at the same time. (I can't separate it out into other gameobjects either).

Bolt Version:
Unity Version:
.NET Version:
+1
Under Review

How about using 2 start events?

Didn't know I could! So that definitely works for that instance which is lovely. Thank you!

The other instances I've used it is a bit trickier. I have a sort of "flow" of logic for game quests.

First you must "build the tea table".

Then you must "clean watches" and "build bookshelves" (in whatever order you like).

You must complete both of those before you can "begin the meeting". (BoltCombine only triggers when all inputs have fired). Effectively a lazy AND gate.

I don't think I can use 2 start events - does it work with two "Input" events? This is embedded inside a super unit.

I've tried to make a new version of Sequence, with a different EnterCoroutine


Is it possible to trigger the outputs without waiting for the first one to finish? or does that massively mess things up.


private IEnumerator EnterCoroutine(Flow flow)
{
    var stack = flow.PreserveStack();

    foreach (var output in multiOutputs)
    {
        yield return output; // Lazlo: Is it possible to trigger the outputs without yield returning here?

        flow.RestoreStack(stack);
    }

    flow.DisposePreservedStack(stack);
}

Answered

Sure, just call flow.Invoke(output); instead of yield return output;.

So I just tried that, unfortunately it generates errors further down the flow because "WaitTimer can only be triggered in a coroutine".  Not sure what I'm trying to do is possible anymore :-/

+2

Hm, well ok now I see what you're trying to. You're trying to start two coroutines simultaneously. That's not what Sequence is for and there's no built-in unit for that.

A "parallel" unit like sequence that starts every one of its outputs as a coroutine could be interesting, I'm making a note to include it in a later version.

A way to do in the mean time that instead of flow.Invoke could be (untested):

        private ControlOutput Enter(Flow flow)
        {
            var reference = flow.stack.ToReference();

            foreach (var output in multiOutputs)
            {
                Flow.New(reference).Run(output, true);
            }
            
            return null;
        }

Note that starting a new flow like this will make your locals/cached/flow variables unavailable past that point, but that's to be expected in any coroutine anyway.

Oh amazing thank you for sharing I'll give that a try later today, much appreciated! :D

+1

Works like a charm, thank you Lazlo! Hugely appreciate it, everything works splendidly now! :D Awesome.

Glad you got it working! Cheers!

Hi Lazlo!

We've just updated to 1.4.2 and unfortunately this line of code no longer compiles

Flow.New(reference).Run(output, true);

If we remove the last parameter it compiles

Flow.New(reference).Run(output);

but we're back to having errors of "WaitUntilUnit" can only be triggered in a cutscene.

Our entire meta-game depends on us being able to start two coroutines simultaneously - is there another work around you'd suggest?

Thanks again,
-Mark

+2

Hi BearHugMark,

You can use this instead now:

Flow.New(reference).StartCoroutine(output);

Hi Lazlo,

It works in Enter. Bravo!  But how can I make it work in EnterCoroutine?

Would you please give me some help?

Thanks

Hi Bai Croissant,

What do you mean exactly by "EnterCoroutine"?

Hi Lazlo, that's awesome! It's worked a treat.

Thanks for the quick-fix :D