Using Sub-Graphs

You are here:
< All Topics
Table of Contents

This tutorial will guide you on how to create sub-graphs and how to use them.

First we will create a new graph.

  1. Right click in the project view and select New / FlowReactor / New Graph

  2. Add a new Debug.Log node

  3. Select the Debug.Log node and click on the create sub-graph button. Alternatively you can also select CTRL+S

  4. You have now created a sub-graph from the Debug.Log node. 

  5. Connect the OnStart node with the Sub-Graph.

You can name the outputs of a sub-graph by entering a name in the ExitGraph nodes.

  1. Open up the Sub-Graph by double clicking on the node.

  2. Inside of the Sub-Graph you’ll find the Debug.Log node but also two additional nodes: OnEnterGraph and ExitGraph. You can have as many OnEnterGraph and ExitGraph nodes as you want. By adding a new ExitGraph node your Sub-Graph node will add an additional output.

  3. Add the message: “Entering Sub-Graph” to the Debug.Log message.

  4. Connect the OnEnterGraph node with the Debug.Log node.

  1. Now add two OnKeyInput nodes and connect each one to a separate ExitGraph node. Assign a key code to each OnKeyInput nodes, and set the Keystate to down

  1. Move one level back to your root. Simply click on the breadcrumb navigation in the toolbar.

  2. Connect on each output of your Sub-Graph node a Debug.Log node. Set the log message of the first Debug.Log node to “A” and the other to “B”. Connect both Debug.Log nodes back to your Sub-Graph, if we don’t connect them back the OnKeyInput nodes would only run for one time.

  3. Now add your graph to a gameobject and hit play. 

    You will see the first “Entering Sub-Graph” message in the console log directly at start. By pressing one of the assigned keys you should see either “A” or “B” in the console.

Sub-Graphs are a great way to control behaviors or sequencing logics. For example: If you would use the character controller graph from the other tutorial you could add the nodes which are controlling the character into a sub-graph. Now you could easily enable or disable the character movement based on other behaviors. 

Privacy Settings
We use cookies to enhance your experience while using our website. If you are using our Services via a browser you can restrict, block or remove cookies through your web browser settings. We also use content and scripts from third parties that may use tracking technologies. You can selectively provide your consent below to allow such third party embeds. For complete information about the cookies we use, data we collect and how we process them, please check our Privacy Policy
Consent to display content from Youtube
Consent to display content from Vimeo
Google Maps
Consent to display content from Google