A game about forced loneliness, made by TACStudios
at master 61 lines 4.2 kB view raw view rendered
1# Subgraph node 2 3Use a Subgraph node to reference and trigger another Script Graph's logic from inside a parent Script Graph. 4 5![An image of the Graph window that displays a new Subgraph node created from an existing Script Graph added to another Script Graph file](images/vs-existing-graph-example-subgraph.png) 6 7For more information on Subgraphs, see [Subgraphs and State Units](vs-nesting-subgraphs-state-units.md). For more information on Script Graphs, see [Graphs](vs-graph-types.md). 8 9## Fuzzy finder category 10 11The Subgraph node is in the **Nesting** category in the fuzzy finder. 12 13You can go to the **Graphs** category and select any Script Graph to create a Subgraph node. For more information on how to create a Subgraph, see [Add a Subgraph to a Script Graph](vs-nesting-add-subgraph.md). 14 15## Available ports 16 17By default, a Subgraph node has no ports. 18 19Use the [Graph Inspector](vs-interface-overview.md#the-graph-inspector) to specify the following on a Script Graph: 20 21- Trigger Inputs. 22- Trigger Outputs. 23- Data Inputs. 24- Data Outputs. 25 26These determine the type and number of ports available on its Subgraph node. For more information on how to define ports on a Script Graph, see [Add a Trigger or Data port to a Script Graph](vs-nesting-add-triggers-data-graph.md). 27 28| **Port type** | **Description** | 29| :------------- | :-------------------- | 30| **Trigger Input** | Adds a control input port to the Subgraph node for the Script Graph. Use a Trigger Input to choose which node or nodes from a parent graph triggers Visual Scripting to run the logic in the Subgraph. | 31| **Trigger Output** | Adds a control output port to the Subgraph node for the Script Graph. Use a Trigger Output to choose which node or nodes Visual Scripting triggers after the logic contained in the Subgraph finishes. | 32| **Data Input** | Adds a data input port to the Subgraph node for the Script Graph. Use a Data Input to receive data from a parent graph. | 33| **Data Output** | Adds a data output port to the Subgraph node for the Script Graph. Use a Data Output to send data back to a parent graph. | 34 35## Example graph usage 36 37> [!TIP] 38> A Subgraph node can use a new blank Script Graph or an existing Script Graph from a project. For more information, see [Add a Subgraph to a Script Graph](vs-nesting-add-subgraph.md). 39 40In the following example, the Subgraph node **Character Move** references a graph that makes a GameObject move based on a user's input. It has the following: 41 42- One Trigger Input port. 43- One Trigger Output port. 44- Three Data Input ports. 45- One Data Output port. 46 47After every Update Event in the application, the **Character Move** Subgraph node triggers and takes the X, Y, and Z coordinates of the current GameObject's Transform component. The Subgraph node then outputs a new Vector 3 value, which the parent graph assigns to the current GameObject with a Transform Set Position node. 48 49![An image of the Graph window. The Output Trigger port on an On Update Event node connects to the Input Trigger port on a Subgraph node called Character Move. A Transform Get Position node gets the position of the current GameObject's transform in a Vector 3. The Transform Get Position node connects its Vector 3 output port to a Vector 3 Get X, Vector 3 Get Y, and Vector 3 Get Z node. The Get X, Get Y, and Get Z nodes connect to the X, Y, and Z data input ports on the Character Move Subgraph node, respectively. The Character Move Subgraph node's Output Trigger port connects to the Input Trigger on a Transform Set Position node, set to the current GameObject's transform. The Character Move Subgraph connects its Vector 3 output port to the Vector 3 input port on the Set Position node.](images/vs-subgraph-node-use-example.png) 50 51The Subgraph node reduces the number of nodes in the parent graph. 52 53> [!TIP] 54> To see the Script Graph attached to the Subgraph node in this example, see either [Input node](vs-nesting-input-node.md) or [Output node](vs-nesting-output-node.md). 55 56## Related nodes 57 58Use a Subgraph node with the following nodes: 59 60- [Input node](vs-nesting-input-node.md) 61- [Output node](vs-nesting-output-node.md)