Skip to main content

Sub-Flow

A Sequine Flow may contain a command that calls another Sequine Flow. So, that Sequine Flow is being run as a sub-flow. A sub-flow can also have another sub-flow. There is no limit on how many stack of sub-flow can be run in a root Sequine Flow.

Here are some cases where a sub-flow can be useful:

  • Reusability. You might have multiple Sequine Flows that partially run the same commands in order. In that case, you can create a Sequine Flow for exactly that part, and then call it in those Sequine Flows as a sub-flow. This is a similar approach to creating reusable functions/methods in programming.
  • Encapsulating. You might not want to have a large Sequine Flow that contains tons of commands. Instead, you can extract them into separate Sequine Flows, each with smaller scope.

Creating a Sub-Flow

There is no difference on how to create a sub-flow. A sub-flow is just a regular Sequine Flow. What makes it a sub-flow is that it is run by a command that runs a sub-flow.

You can use either Sequine Flow Asset or Sequine Flow Component as a sub-flow.

tip

You can also drag and drop a Sequine Flow Asset or a Sequine Flow Component to nodes area as a shortcut to automatically create a Run Sub-Flow command.

Running a Sub-Flow

In Sequine Flow's editor, create a new Run Sub-Flow command by right clicking on the empty area, and choose Flow -> Run Sub-Flow (Asset).

Run Sub-Flow

By now, you might notice that there are 2 versions of Run Sub-Flow command. This refers to the object type of Sequine Flow to be used as the sub-flow. Run Sub-Flow (Asset) means that we are calling a Sequine Flow Asset as the sub-flow.

1. Run Sub-Flow (Asset) Command

This command will run a Sequine Flow Asset as the sub-flow.

We will talk about Branch command later in Branch section. But this is an example of how to choose which sub-flow to execute, given a condition called ShouldRunFlow1. Here we can see that Run Sub-Flow (Asset) command requires a field called Sequine Flow Asset.

Run Sub-Flow

2. Run Sub-Flow (Component) Command

This command will run a Sequine Flow Component as the sub-flow.

Since Sequine Flow Component is an object of a scene, we can choose either of the 3 ways to target the flow component. Read Cross-Scene System if you haven't already.

Run Sub-Flow Component

3. Exiting a Sub-Flow

By default, a sub-flow will exit, and return to its parent flow when the sub-flow has been through all of its default outputs. But, this is quite ambiguous and makes it rather unusable in previous versions (v1.4.0 and below), since most sequences involve the use of non-default outputs (such as On Complete output in Play Animation Clip command).

This is no longer the case in current version.

Exit Sub-Flow Command

Since version 1.5.0, Exit command is introduced, which can be switched on and off. When switched off, the default exit condition is used. But, when it switched on, then the sub-flow will be exited once the Exit command is executed. This is the reason why it receives a main in-point.

Passing Input Parameters

As of version 1.7.0, we can also pass input values to a sub-flow. The input parameters are defined using Variables which we'll cover right in the next section.