A game about forced loneliness, made by TACStudios
1# Attach a graph file to a Script Machine or State Machine 2 3To use a Script Graph or State Graph file in your project, you must attach it to a Script Machine or State Machine. 4 5A Script Machine or State Machine is a component. Components attach to GameObjects, and help define their behavior. For more information on components and GameObjects, see [Using components](https://docs.unity3d.com/2021.1/Documentation/Manual/UsingComponents.html) or [GameObjects](https://docs.unity3d.com/2021.1/Documentation/Manual/GameObjects.html) in the Unity User Manual. 6 7## Add a Script Machine or State Machine component to a GameObject 8 91. [!include[open-hierarchy](./snippets/vs-open-hierarchy-window.md)] 10 111. In the Hierarchy window, select a GameObject where you'd like to add a Script Machine or State Machine. 12 132. [!include[open-inspector-window](./snippets/vs-open-inspector-window.md)] 14 153. In the GameObject's Inspector window, select **Add Component**. 16 17 The Components menu opens. 18 194. Do one of the following: 20 - To add a Script Machine or State Machine, in the Components menu, go to **Visual Scripting** and select **Script Machine** or **State Machine**. 21 - Use the search bar to find the Script Machine or State Machine component. 22 23The new Script Machine or State Machine component appears in the Inspector window for the GameObject: 24 25![A new blank Script Machine component in the Inspector window for a GameObject](images\vs-script-machine-blank.png) 26 27## Attach a graph file to the Script Machine or State Machine 28 291. In the Inspector window, locate your Script Machine or State Machine component. 30 311. Set the **Source** to **Graph**. 32 332. Do one of the following: 34 - In the **Graph** field, select the object picker (circle icon) and choose a compatible graph file from your project. 35 - Click and drag a file from your Project window and drop it into the **Graph** field. 36 37For more information on how to create Script or State Graphs, see [Create a new graph file](vs-create-graph.md). 38 39## Next steps 40 41After you attach a graph to a Script Machine or State Machine, you can open the graph and edit. For more information, see [Open a graph file](vs-open-graph-edit.md).