# Editor Graph

The editor graph works and look pretty much like the Animator graph, this is the editor for the **State Machines** they are composed of nodes with **Actions**, **Triggers** and **Transitions** where you can add **Conditions.**

![Example of a Connection Manager which takes care of room creation and player instantiation](https://3895715781-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LDchaEIEhpBAh2gCe06%2Fuploads%2Fgit-blob-f8650de38318968fbb03c182a6c76eeb8eb94421%2Fimage.png?alt=media)

## The State Machine asset

To create a Behavior Graph asset right click on your Project Panel and select **`Create → Game Creator → State Machine`**. You can name it however you want as well as place it anywhere.

{% hint style="success" %}
I recommend creating a **`State Machines/`** folder at the root of your project and organize all your trees there.
{% endhint %}

{% hint style="success" %}
**State Machines** can be duplicated by simply selecting the SM asset and press **CTRL+D**
{% endhint %}

## The Controller

In order to **run** a **State Machine** you have to use a **State Machine Controller** component. You can add it manually to a Game Object or simply drag and drop a **State Machine asset** in an object this will auto-create a State Machine Controller and assign the State Machine reference.

![](https://3895715781-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LDchaEIEhpBAh2gCe06%2Fuploads%2Fgit-blob-e4030717ef1616e32191993c8ff14f1d969faf52%2FScreen%20Recording%202021-02-13%20at%2010.07.05%20PM.2021-02-13%2022_08_01.gif?alt=media)

## The State Machine Graph Window

To bring up the StateMachine Graph window simply go to the top toolbar and select **`Window → State Machine`**. Alternatively, when you double click on a **State Machine** asset it will automatically open the window.

![(A state machine with a transition selected)](https://3895715781-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LDchaEIEhpBAh2gCe06%2Fuploads%2Fgit-blob-0e08261a93cc49c6e1e960489b93c5d7f3db8985%2Fimage.png?alt=media)

## Live debugging

When playing Unity you can preview where the State Machine is currently running.

![](https://3895715781-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LDchaEIEhpBAh2gCe06%2Fuploads%2Fgit-blob-246c97376dee2013662315f74099a8caa6b1e0be%2Fimage.png?alt=media)

## Context Menus

Once you right click somewhere in the Graph it will show a different context menu depending on what you have selected.

![](https://3895715781-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LDchaEIEhpBAh2gCe06%2Fuploads%2Fgit-blob-b6fbfa0f3e4d49ad967a83fd28876cbc69f73426%2FScreen%20Recording%202021-02-12%20at%201.15.00%20PM.2021-02-12%2013_25_48.gif?alt=media)

## Export

One neat feature of the State Machine is that you can easily export them to re-use them on other projects.

![](https://3895715781-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LDchaEIEhpBAh2gCe06%2Fuploads%2Fgit-blob-341a3958ba9a0ed992de9dd7b9ee355750851055%2FScreen%20Recording%202021-02-13%20at%207.44.38%20PM.2021-02-13%2019_54_54.gif?alt=media)

{% hint style="info" %}
This option will package a SM in a Unity Package containing the SM with all its nodes, actions, conditions and triggers.
{% endhint %}
