What is Sequence good for?

I’ve seen many times that in official Unreal tutorials, they use Sequence flow control.

Can someone tell me how that is different from normal execution order?

I mean, for example, what difference is there between the following?

Event Begin Play->Create Widget X->Add to Viewport(X)->Create Widget Y->Add to Viewport(Y)

and

Event Begin Play → Sequence Output 1 → Create Widget X → Add to Viewport(X)

…Sequence Output 2 → Create Widget Y → Add to Viewport(Y)

Will there be a difference in execution order? If yes, how?

Also, are there advantages or disadvantages of using one or the other, or is it just a matter of preference?

2 Likes

They are both the same. Sequence helps you keep things tidier. Keep in mind that there is execution order in sequence pins so, for instance, you may not want to Set a variable with Pin 2 if you need it in a function at Pin 1.

1 Like

Obviously. That’s what I thought. I just wanted to make sure that it’s only a matter of preference. Thanks for your answer

One thing i would like to mention is that Sequence dont respect latent functions. For example, if you have a Delay node on Pin 1, Sequence dont bother waiting for that delay to finish. It will immediately run Pin 2.

For example, the below sequence will cause Accessed None Error:

where as this one works:

2 Likes

I normally use them for Boolean checks in a function with a single return node, an example would be to use one function for a range of things like a pickup, have the Sequence goes though each type, ammo, health, power ups and so on, then have the last execution return which item it is, there great as you only need the one return node depending on your logic needs.

I am wondering, is this also happening if the sequence node 1 have a very long execution ? Will sequence 2 wait for the very long execution, or will it be executed before ?

It will wait until 1 is done. Latent functions are a exception since they basicly end the execution flow and continue at a later point. But everything else will execute in order no matter how long it takes.