# Visual Scripting

The new Monaverse Developer Kit includes the ability to create custom experiences using Visual Scripting. &#x20;

Visual scripting is a method of creating game logic using a visual interface instead of writing code in another programming language. This makes it easier for creators to make incredible experiences, all inside Unity 3d.&#x20;

Visual Scripting is available in all Mona spaces using the Unity 2022 Mona SDK.&#x20;

{% hint style="danger" %}
**Note: Please update to the latest version of the Mona SDK here before using Visual Scripting**: <https://github.com/monaverse/SpaceStarter>
{% endhint %}

### Importing the Visual Scripting Asset to Unity3D

* You may need to import the Visual Scripting asset from the Package Manager. Go to 'Window/Package Manager' and select 'Packages : Unity Registry' at the top.
* Scroll down to 'Visual Scripting', then select 'Install' at the top right of the window.

### Adding a Visual Scripting graph

Visual Scripting is done as a component on an asset. For the purposes of this tutorial, we will add a graph to a simple cube, but of course you can add it to anything you want.

* With the asset selected, select 'Add Component' in the Inspector.
* Type in 'Script machine' (or enough to pull that up or scroll down to the 'Visual Scripting' menu and select 'Script Machine'.
* The source defines where the graph is found.&#x20;
  * Embed adds the script to the asset itself. You can add a Title and a Summary if you wish.

<figure><img src="https://3438761929-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MkgZbQzoznBJC_ld633%2Fuploads%2F89utB3gU0F03RNiVn1JX%2Fimage.png?alt=media&#x26;token=e7181707-9274-4667-8671-3da417bd2d81" alt=""><figcaption><p>Embed Options</p></figcaption></figure>

* The other source option is Graph.
  * &#x20;Graph creates an external graph file that you could use on other assets.
  * If you select Graph, select 'New' to save your new visual script graph to your assets. The Title and the Summary are available in the graph itself.

<figure><img src="https://3438761929-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MkgZbQzoznBJC_ld633%2Fuploads%2F95AW5GbtjSX6KS28cCFh%2Fimage.png?alt=media&#x26;token=d2b146e2-2437-4610-8ec2-cbe06fc44da8" alt=""><figcaption><p>Graph Options</p></figcaption></figure>

* At the base you have 'Edit Graph' which is where you start creating your nodes.

### The Node Graph

The Node Graph is where all the magic happens. Think of it much like a story going from left to right where each node happens over time.

There are two base nodes, On Start and On Update  :&#x20;

* 'On Start' happens once at the very beginning of the assets 'life'. Anything that you need to setup for the asset initially stems from here.
* 'On Update' happens every time the frame is updated, so these nodes will be played out all the time.

<figure><img src="https://3438761929-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MkgZbQzoznBJC_ld633%2Fuploads%2FjuZFDB5T8X59wqtFaCAT%2Fimage.png?alt=media&#x26;token=b9efd184-abe0-4ed0-bd23-f961a49b5ec0" alt=""><figcaption><p>The Visual Scripting Node Graph</p></figcaption></figure>

### Adding Nodes

* There are two ways to add a node :&#x20;
  * Right click on the graph and then search for the node you are after
  * Drag an arrow from a node, once you let go you can search for the node you are after.
* If you create nodes without using the connection you can connect nodes simply by dragging from the arrows to the left and right of nodes.
* It is possible to delete connections by right clicking on the arrows on the left/right of the node.
* You can create Groups easily by holding Ctrl and left drag to create a Group node. If this surrounds multiple nodes, you can move them all easily.&#x20;
  * You can rename the group by clicking the label once.&#x20;
  * Delete the group by selecting it and pressing 'Delete', or right click and select 'Delete'.

### Supported Nodes

At the moment the Nodes you can use are limited, and growing every day. If there is a Node that you would like to use that isn't included you can easily request it in our [Discord](https://www.monaverse.com/discord), or submit a request [here](https://airtable.com/shro8C407UAL78Qwc). Currently the main node types fall under the following categories :&#x20;

* mscorlib
* UnityEngine.CoreModule
* UnityEngine.AudioModule
* UnityEngine.PhysicsModule
* UnityEngine.AnimationModule
* UnityEngine.UIModule
* UnityEngine.UI
* Unity.TextMeshPro
