A game about forced loneliness, made by TACStudios
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
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
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)