2.3 KiB
Create and assign a graph to a new GameObject
You can use the empty graph creation flow to create a new graph file and assign it to a new GameObject. Visual Scripting automatically creates a new GameObject with the required components for the new graph file.
For more information on other ways to create a graph file, see Create a new graph file.
To create a new graph and assign it to a new GameObject:
-
[!includeopen-hierarchy-window]
-
In the Hierarchy window, select the GameObject where you want to assign the new graph.
-
[!includevisual-scripting-window]
-
Expand Create new Script Graph.
-
Select on new game object.
-
Choose a location to save the new graph file.
-
Enter a name for the graph.
-
Select Save.
[!NOTE] The GameObject you create with this method has the same name as the graph file. After you have named and saved the graph file, the GameObject appears in the Hierarchy.
The new graph file automatically opens in a new window.
Create a State Graph
To create a new State Graph and assign it to a new GameObject:
-
[!includeopen-hierarchy-window]
-
In the Hierarchy window, select the GameObject where you want to assign the new graph.
-
[!includevisual-scripting-window]
-
Expand Create new State Graph.
-
Select on new game object.
-
Choose a location to save the new graph file.
-
Enter a name for the graph.
-
Select Save.
[!NOTE] The GameObject you create with this method has the same name as the graph file. After you have named and saved the graph file, the GameObject appears in the Hierarchy.
The new graph file automatically opens in a new window.
Next steps
After you create your new graph, attach it to a Script Machine or State Machine to use it in your application. For more information, see Attach a graph file to a Script Machine or State Machine.