A FlowGraph Module is a way to encapsulate nodes as its own graph that can then be fetched from other graphs at runtime.
Using Flow Graph Editor, you can create a new Module by selecting File -> New FG Module -> Global/Level.
You can also create a new Module by right-clicking on the FG Modules entry.
Existing logic can be converted to a module by selecting and copying the desired nodes, and then right-click to select Paste With Links (Ctrl + Shift + V) option in a new module.
There are two supported module types:
Saved in: ../GameSDK/Libs/FlowgraphModules
Saved in: ../GameSDK/Levels/<levelfolder>/FlowgraphModules
Custom Ports for Input and Output can be added via Tools -> Edit Module when the module's graph is open in the main view:
The Module Ports dialog can also be accessed by right-clicking on the module in the graphs list or by right-clicking its related nodes.
Modules are called from other graphs by using Call Nodes. Every module has its own call node named Module:Call_<Module Name>.
Modules can be called independently by distinct Call Nodes and from different graphs. Every call to the module will generate a separate Instance that runs independently from previous calls.
The specific Instance associated to the Call node can be controlled with the 'InstanceID' port. This is useful to update the inputs or listen for outputs of a specific instance.
When you set the value as '-1', it will generate a new instance with an automatic ID. The Call Node will output for that instance until it is called again.
Subsequent triggers in a Call node with a specific instance ID will update the inputs of that instance and not generate a new one. The instance ID numbers are independent from module to module.
A Module Instance can run associated with an Entity by setting it in the Choose Entity
port. The Entity ID is available from within the module in the Start node's EntityID
port.
The Entity ID can be used to reference the same module instance to update its inputs and listen to outputs. The Instance ID should be kept at -1.
Another way to run modules on entities is by using the node GameEntity:Containers:Actions:
This node runs a module on all entities of an entity container where all instances will automatically have the correct Entity ID.
There is no way to pass in inputs with this method.
Without the Continuous Input
option (default), a module instance will only receive updated inputs when the Call
port is triggered, which activates all the start node's ports even if the input values were not updated.
With the Continuous Input
option, single inputs will be passed into the start node as soon as they are triggered, which will also activate the start node's Update
port. If the Call node does not have a running Instance and an input is triggered, nothing happens.
For Continuous Output,
the Call Node will update its output ports as soon as they are activated from the return node.
Without Continuous Output
the Call Node's outputs will only activate when the Instance is successfully finished.
The Call node can be set to Global Controller
mode. This is useful for either sending inputs to all instances of the module at once or for listening if any of the instances has triggered an output.
OnCalled
port triggers with the InstanceIDs when an instance of the module is created.The following nodes are used as Module Utility Nodes:
Based on the name (or partial name) of a module, displays the module's Instances that are running.
This node is used to make a registry of Instance IDs of a module. Instance IDs for a Module can be stored (Set
) along with an UserID
which can be anything that is useful and logical to associate. These connections can then be retrieved (Get
) using that User ID
. The node does not store any information by itself, all the associations are to be created and maintained by the designer.
It is possible to get an overview of actively running module instances in the game with the CVar fg_debugmodules.
It is possible to call a module from within itself and also to listen for the module's own outputs inside its graph. While there are uses for this, beware that simply calling new instances of a module infinitely will eventually crash the engine.
Entities can also run multiple instances of the same module by specifying an Instance ID other than -1. Details on Instance IDs: