# Welcome!

This is 'official' docs page for Ninjutsu Games modules for Game Creator!

In this page you'll learn everything you need to use **Ninjutsu Games** modules for [**Game Creator**](https://www.ninjutsugames.com/go/game-creator-2?src=docs_home_game_creator)

> **Game Creator** is an ecosystem that gives [Unity](https://unity3d.com/) developers a world class technology platform from which they can build games that work seamlessly across multiple platforms quickly and efficiently.

## Game Creator 2 Modules

<table data-card-size="large" data-view="cards" data-full-width="false"><thead><tr><th></th><th data-hidden></th><th data-hidden></th><th data-hidden data-card-cover data-type="files"></th><th data-hidden data-card-target data-type="content-ref"></th><th data-hidden data-type="users" data-multiple></th><th data-hidden data-type="content-ref"></th></tr></thead><tbody><tr><td><strong>Fusion Module</strong></td><td></td><td></td><td><a href="/files/ocqFFGl3AenRDrH4kHrc">/files/ocqFFGl3AenRDrH4kHrc</a></td><td><a href="/pages/Ag988yh82xVITeZI31Cw">/pages/Ag988yh82xVITeZI31Cw</a></td><td></td><td></td></tr><tr><td><strong>Factions</strong></td><td></td><td></td><td><a href="/files/Q5IowxLJlcyUSLa9i2hX">/files/Q5IowxLJlcyUSLa9i2hX</a></td><td><a href="/pages/VIt02EMiJ2ADGRsAXhvM">/pages/VIt02EMiJ2ADGRsAXhvM</a></td><td></td><td></td></tr><tr><td><strong>State Machine 2</strong></td><td></td><td></td><td><a href="/files/QaWnDFUI0Ii0vrEKip1n">/files/QaWnDFUI0Ii0vrEKip1n</a></td><td><a href="/pages/4M8a87cXAyv359Oza8F2">/pages/4M8a87cXAyv359Oza8F2</a></td><td></td><td></td></tr><tr><td><strong>Loot Locker</strong></td><td></td><td></td><td><a href="/files/WGs1MEq625MWVxjJV5Px">/files/WGs1MEq625MWVxjJV5Px</a></td><td><a href="/pages/K0XFcJDgHGbr4GVDlZug">/pages/K0XFcJDgHGbr4GVDlZug</a></td><td></td><td></td></tr><tr><td><strong>Photon Module 2</strong></td><td></td><td></td><td><a href="/files/ul4COmwLQ8nDW0jew2FC">/files/ul4COmwLQ8nDW0jew2FC</a></td><td><a href="/pages/RTdP1ZChuCLq7hdKYJtg">/pages/RTdP1ZChuCLq7hdKYJtg</a></td><td></td><td></td></tr><tr><td><strong>Photon Stats</strong></td><td></td><td></td><td><a href="/files/fCdbfuuAG5Y9hEMKzuQr">/files/fCdbfuuAG5Y9hEMKzuQr</a></td><td><a href="/pages/XZvJAwZceweCrK0VFLKj">/pages/XZvJAwZceweCrK0VFLKj</a></td><td></td><td></td></tr><tr><td><strong>Photon Abilities</strong></td><td></td><td></td><td><a href="/files/RvT3ckoVlniZkE8K8mSq">/files/RvT3ckoVlniZkE8K8mSq</a></td><td><a href="/pages/rHHuOTrEw0YcksXLSr8z">/pages/rHHuOTrEw0YcksXLSr8z</a></td><td></td><td></td></tr><tr><td><strong>Photon Inventory</strong></td><td></td><td></td><td><a href="/files/UzNkTPqrk4ECCy1oyfp8">/files/UzNkTPqrk4ECCy1oyfp8</a></td><td><a href="/pages/bPMIcy2dRLldD11CA1YD">/pages/bPMIcy2dRLldD11CA1YD</a></td><td></td><td></td></tr><tr><td><strong>Photon Melee 2</strong></td><td></td><td></td><td><a href="/files/mpF3EkSaRNoEXcIMUYdL">/files/mpF3EkSaRNoEXcIMUYdL</a></td><td><a href="/pages/CywmvuktBqp0YocXw08D">/pages/CywmvuktBqp0YocXw08D</a></td><td></td><td></td></tr><tr><td>Coop (Coming Soon)</td><td></td><td></td><td></td><td><a href="/pages/4NX26f94wCnoyIXtm3yt">/pages/4NX26f94wCnoyIXtm3yt</a></td><td></td><td></td></tr></tbody></table>

## Game Creator 1 Modules

<table data-view="cards"><thead><tr><th></th><th data-hidden></th><th data-hidden></th><th data-hidden data-card-target data-type="content-ref"></th><th data-hidden data-card-cover data-type="files"></th></tr></thead><tbody><tr><td><strong>Photon Module 1</strong></td><td></td><td></td><td><a href="/pages/-LGSvRK9fOni1jCeJ3DY">/pages/-LGSvRK9fOni1jCeJ3DY</a></td><td><a href="/files/v9q7eNXPa2ACsIyMKqVl">/files/v9q7eNXPa2ACsIyMKqVl</a></td></tr><tr><td><strong>State Machine 1</strong></td><td></td><td></td><td><a href="/pages/-MTHEDwKBCrXu_1jVpGR">/pages/-MTHEDwKBCrXu_1jVpGR</a></td><td><a href="/files/11ts63zWnMoUXCcd0qHN">/files/11ts63zWnMoUXCcd0qHN</a></td></tr><tr><td><strong>Photon Traversal 1</strong></td><td></td><td></td><td><a href="/pages/-Md4ThZsIH03_zuOUkb-">/pages/-Md4ThZsIH03_zuOUkb-</a></td><td><a href="/files/T5zJaelO2LWlYmkjuSA4">/files/T5zJaelO2LWlYmkjuSA4</a></td></tr><tr><td><strong>Photon Melee 1</strong></td><td></td><td></td><td><a href="/pages/-Md4TlhygPJ2NPOHLpIC">/pages/-Md4TlhygPJ2NPOHLpIC</a></td><td><a href="/files/oGRvrOTxNZJIVF0klE2i">/files/oGRvrOTxNZJIVF0klE2i</a></td></tr><tr><td><strong>Photon Shooter 1</strong></td><td></td><td></td><td><a href="/pages/-MD6D4a6vEfzQZ-6yrek">/pages/-MD6D4a6vEfzQZ-6yrek</a></td><td><a href="/files/Xq9gyTBCFni4QAL3zAIm">/files/Xq9gyTBCFni4QAL3zAIm</a></td></tr></tbody></table>

{% hint style="success" %}
Join our [Discord server](https://discord.com/invite/99bbWBzKDX)!
{% endhint %}

{% hint style="info" %}
Have any question? Feel free to drop us a line at <support@ninjutsugames.com>.
{% endhint %}

{% hint style="info" %}
These guides are maintained alongside every Unity and Game Creator update. If they save you time, you can [support ongoing compatibility work](https://www.buymeacoffee.com/hjupter).
{% endhint %}


# Fusion Module

Photon Fusion module for Game Creator 2

## Overview

Elevate your multiplayer game development with the Fusion 2 Module for Game Creator 2, designed to seamlessly integrate Photon Fusion’s cutting-edge networking capabilities into your project.

This module ensures precise and efficient synchronization of characters, objects, and variables across all clients, delivering a smooth multiplayer experience.

{% embed url="<https://youtu.be/eDtCsUxewmc>" %}

{% hint style="success" %}
Play the [**Demo**](https://hjupter.itch.io/fusion-gamecreator-2) now!
{% endhint %}

{% hint style="success" %}
[**Get Fusion Module on the Unity Asset Store →**](https://www.ninjutsugames.com/go/fusion?src=docs_fusion_overview)
{% endhint %}

## Key features

* **Complete Character Synchronization:** Synchronize player characters across the network effortlessly.
* **Seamless RPCs:** Use RPCs for real-time, networked interactions in Actions, Triggers, and Conditions.
* **Intuitive UI:** Build multiplayer interfaces with ready-to-use UI elements for Session Lists, Region Selection, and more.
* **Engaging Room Chat:** Enhance player communication with built-in room chat featuring visually appealing floating bubble messages.
* **Networked Variables:** Synchronize Local and Global NamVariables and ListVariables to manage player lists, models, and more.
* **Automatic Look Tracking:** Characters automatically track and look at networked objects, enhancing interaction and immersion.
* **Character Attachments Synchronization:** Sync character attachments like weapons, gear, and cosmetics for consistent item visibility.
* **Comprehensive Network-Ready Features:** Leverage a wide array of network-ready Actions, Conditions, Triggers, and properties.
* **Properties:** The Game Creator 2’s robust properties system provides seamless access to essential network information from any session, including the current session, lobby, or player. This includes ping, username, and other vital data.
* **Network Topologies:** All Fusion 2 topologies are supported
* **Demos:** Plenty of demo scenes to understand and get you started
* **Full Compatibility:** Works seamlessly with all Game Creator modules.
* **Documentation:** Includes thorough setup and implementation guidance.

{% hint style="info" %}
All actions and conditions are compatible with other Game Creator modules.
{% endhint %}


# Setup

Welcome to getting started with the Factions module. In this section, you’ll learn how to install this module and get started with the examples it comes with.

## Prepare your Project

Before installing the **Fusion** module, you’ll need to either create a new Unity project or open an existing one.

{% hint style="warning" %}
It is important to note that [**Game Creator 2**](https://www.ninjutsugames.com/go/game-creator-2?src=docs_fusion_setup_game_creator) and [**Photon Fusion**](https://www.ninjutsugames.com/go/photon-fusion?src=docs_fusion_setup_sdk) should be present before attempting to install this module.
{% endhint %}

## Install the Fusion module

If you haven't purchased the module, [**get Fusion Module on the Unity Asset Store →**](https://www.ninjutsugames.com/go/fusion?src=docs_fusion_setup_module), then follow the steps below to install it.

Once you have bought it, click on **Window → Package Manager** to reveal a window with all your available assets.

Type in the little search field the name of this package and it will prompt you to download and install the latest stable version. Follow the steps and wait till Unity finishes compiling your project.

## Examples

We highly recommend checking the examples that come with the **Fusin** module. To install them, click on the *Game Creator* dropdown from the top toolbar and then the *Install* option.

The **Installer** window will appear and you'll be able to manage all examples and template assets you have in your project.

* **Examples**: A collection of scenes with different use-case scenarios
* **UI**: A bundle of common user interface elements

<figure><img src="/files/B2yzxvbFBSW4CA9vCT1K" alt=""><figcaption></figcaption></figure>

{% hint style="success" %}
Clicking on the **Examples** install button will install all dependencies automatically.
{% endhint %}

Once you have the examples installed, click on the *Select* button or navigate to `Plugins/GameCreator/Installs/Fusion.Examples/`.

<figure><img src="/files/Hv6w1cAmZjwryVotZTVC" alt=""><figcaption></figcaption></figure>

## Getting Started

This module requires Fusion to be installed first. After you have imported Fusion you need to set-it up and create your App Id in order for this to work.

You can follow this getting started [**guide from Fusion**](https://doc.photonengine.com/fusion/current/tutorials/shared-mode-basics/1-getting-started)


# Sessions

To start a network session with Fusion Module all you need is the **Start Game** instruction.

<figure><img src="/files/QqGtAjKENybtuY0KGkmc" alt=""><figcaption></figcaption></figure>

Once connected to fusion you can use **On Scene Load Done** to spawn your player prefab.

<figure><img src="/files/089fZ3TgD96LcmrNX28R" alt=""><figcaption></figcaption></figure>

## Start Game Parameters


# Characters

## Overview

The **Network Character** is the component resposible for synchronizing player's movement, rotation, jump, attachments, ragdoll state, model change, look tracking and more.

{% hint style="success" %}
This works with any type of controller like Navmesh, Tank, Rigidbody etc.
{% endhint %}

***

## Setup

Setting up a Game Creator character for Fusion is simple. Just attach a **`Network Character`** component, and it will automatically add all the necessary components, making it ready to use.

<figure><img src="/files/25UB1rtq7mYhu6tudFIk" alt=""><figcaption></figcaption></figure>

***

## Attachments

To synchronize attachments the objecs needs to be registered first, you can do this by using **Local List Variables Network** or **Gloal List Variables Network** and select the Attachments sync mode.

<figure><img src="/files/QDq7vXnr5VIlgUMyk9yA" alt=""><figcaption></figcaption></figure>

Once attachmets are registered you can use regular GC2 instructions to attach or remove objects

<figure><img src="/files/v9hWQRcvEfrm8z5FthkB" alt=""><figcaption></figcaption></figure>

***

## Models

Models work the same way attachment does using **Local List Variables Network** or **Gloal List Variables Network** and select the **Models** sync mode

<figure><img src="/files/nCGN8oOvJzqysqr4oM82" alt=""><figcaption></figcaption></figure>

Once models are registered you can use regular Change Model instructio from GC2.

<figure><img src="/files/Vm0XACVikkt6HBbCTOAF" alt=""><figcaption></figcaption></figure>

### Model Config

Models comes with a special variable type to use.

{% hint style="success" %}
Values like **Name, Prefab** and **Sprite** can be used to display a list of characters
{% endhint %}

<figure><img src="/files/e2UIncNkAHIJ5zw3X57B" alt=""><figcaption></figcaption></figure>

### Properties

The fusion module includes properties for this new Model Config variable type like:

* **Model Prefab** (Game Object)
* **Model Name** (String)
* **Model Prefab Name** (String)
* **Selected Model** (String)
* **Model Sprite** (Sprite)
* **Selected Model Sprite** (Sprite)


# Variables

## Overview

Fusion module has built-in components to synchronize Local or Global Name Variabes and Lists.

{% hint style="info" %}
They all require to exist in a scene with a **Network Object** in order to work.
{% endhint %}

{% hint style="success" %}
These components, besides synchronizing their current state to remote players, will replicate the state to newly joined players.
{% endhint %}

## Local Name Variables

To synchronize Local Name Variables simply attach a Local Name Variables Netwok component.

<figure><img src="/files/BTBFd3dbOYdz2MylPAYS" alt=""><figcaption></figcaption></figure>

## Global Name Variables

To synchronize Global Name Variables create a new game object, attach a **`Global Name Variables Netwok`** then select the Global Name Variables you need

<figure><img src="/files/w6J0mRU1LWhln3yU7bXE" alt=""><figcaption></figcaption></figure>

## Local List Variables

To synchronize Local List Variables simply attach a Local List Variables Netwok component and select **Sync Mode** to **Sync Data**

<figure><img src="/files/0wtG1J6yK9xZv5Xnh6iM" alt=""><figcaption></figcaption></figure>

## Global List Variables

To synchronize Global List Variables create a new game object, attach a **`Global List Variables Netwok`** then select the Global List Variables you need and select **Sync Mode** to **Sync Data**

<figure><img src="/files/oBj7ZOpdiUjrcKPcATcu" alt=""><figcaption></figcaption></figure>

## List Sync Modes

List Network components has 4 different types of synchronization modes:

### **Sync Data**

This mode will sync state of list data

### **Players List**

This mode will populate the list with all players and update it as they join or leave.

### **Attachments**

This mode is meant to be used to register attachment props through the network, once props are registered you can freely use Attach or Remove Prop instructions and it wil automatically replicate the attachments.

{% hint style="success" %}
You can read more about this [**here**](/game-creator-2/fusion-module/characters#attachments).
{% endhint %}

### Models

This mode is meant to be used to register models or skins through the network, once props are registered you can freely use Change Model instructions and it wil automatically replicate it.

{% hint style="success" %}
You can read more about this [**here**](/game-creator-2/fusion-module/characters#models).
{% endhint %}


# Remote Procedure Calls

## Overview

Remote Procedure Calls, simply referred to as RPCs, are ideal for sharing punctual game events.

The Fusion module has 3 types of RPCs:

#### Action RPC

<div align="left"><figure><img src="/files/psbJ4CxxYjWImiNdvPv8" alt=""><figcaption></figcaption></figure></div>

#### Condition RPC

<figure><img src="/files/JoqfF0nCnA8UOqtjTQBE" alt=""><figcaption></figcaption></figure>

#### Trigger RPC

<figure><img src="/files/w5JONB57kxWibB7V7oQR" alt=""><figcaption></figcaption></figure>

All of them work the same as the original Run instructions from Game Creator 2 except that they run through the Fusion network, and the target object requires a NetworkObject.

## Parameters

### **RPC Target**

**`RpcTarget`** define on which it is executed.

* `All`: can be sent / is executed by all peers in the session (including the server).
* `Proxies`: can be sent / is executed by a peer who does not have either Input Authority or State Authority over the object.
* `InputAuthority`: can be sent / is executed by the peer with Input Authority over the object.
* `StateAuthority`: can be sent / is executed by the peer with State Authority over the object.

### **Cache State**

If enabled, the state of the trigger will be cached and sent to newly connected peers.

### Remove Cached State

If you need to remove the cached state of any of the RPCs you can use the appropriate instructio for each type of RPC.

<figure><img src="/files/VLFt6w1zZLBf7WLC7pMz" alt=""><figcaption></figcaption></figure>


# Settings

In the Fusion settings, you can configure various aspects of this module:

<figure><img src="/files/NcV0PbsgGrKEWiP8WAZO" alt=""><figcaption></figcaption></figure>

## Default Player Name

This is the predefined player name that will be used when a player doesn't have a username set.

## Session Code Generator

Generates human-readable, random codes that can be shared with other players.

## Regions

Here are the available regions you can select from. You can disable the regions you do not wish to display.


# User Interface

The **Fusion** module comes with a collection of components designed to streamline the creation of UI windows and elements.

All examples that come with the module have been created with them and are flexible to accommodate any type of window.

***

## Session List UI

This is one of the most important components and allows to display a list of avalable sessions to join.

<figure><img src="/files/4hBHQQFeZf20ztnCXMmt" alt=""><figcaption></figcaption></figure>

The **Content** field defines the `Rect Transform` where each prefab instance will be instantiated, for every visible session.

{% hint style="info" %}
The **Content** value should contain an auto-layout component, such as `Vertical Layout Group`, `Horizontal Layout Group` or `Grid Layout Group`.
{% endhint %}

The **Prefab** is the prefab instantiated inside the *Content*. It must contain a **Session Item UI** component, which is automatically configured by its parent.

The **Empty Message** is an option message to display when session list is empty.

The **Sort Direction** field determines the order in which members are displayed based on the sort field index.

The **Sort Index** specify the index of the session property to sort by. This allows for flexibility in sorting by different criteria, such as sessio name, player count, sessio properties and more.

<figure><img src="/files/e1nXmvoVBem7SnF8AOCW" alt=""><figcaption></figcaption></figure>

{% hint style="success" %}
The Fusion UI package provides a ready-to-use prefab for the session list.
{% endhint %}

{% hint style="info" %}
Sessions marked as not visible are not displayed here.
{% endhint %}

## Session Item UI

The Session Item UI component is designed to represent individual entries within the session list, displaying various properties of a session.

<figure><img src="/files/olfcvMKHmcCV3elHCIGz" alt=""><figcaption></figcaption></figure>

The **alternate background** option allows you to set an alternate background image for the scoreboard item, which can help distinguish between different rows for better readability.

The **Join Button** is required to allow playes to join the specifc session, this button can be disabled if the session is not open.

### The fields

Fields can be customized to display specific data of types **string** or **number**.

The **Text** field is the component that displays the data

**Use Format** enables the formatting feature for the associated text or number field.

{% hint style="info" %}
**Percentage Formatting**\
Use `{0:P}` to convert 0.99 to 99%.

**Currency Formatting**\
Use `{0:C}` to convert 1000 to $1,000.00.

**Number Formatting**\
Use `{0:N}` to convert 1000 to 1,000.
{% endhint %}

**Use Color** enables the option to apply color to the field using properties

{% hint style="success" %}
You can use fields to display **session properties** as well.
{% endhint %}

***

## Region Selection

It is possibe to display availabe regions by attaching a **RegionDropdownUI** component in a DropDown menu. This will display enabled regions in [**Fusion Module Settings**](/game-creator-2/fusion-module/settings).

<figure><img src="/files/dUDNNQa6NLq2UGWY00RR" alt=""><figcaption></figcaption></figure>

{% hint style="success" %}
The **selected** region by this drop menu will be stored in player prefs. The selected region is accessibe through a Game Creator 2 string property.
{% endhint %}

## Room Chat

The Room Chat component is designed to facilitate real-time communication between players within a game session. It offers various customizable options to enhance the chat experience, ensuring smooth interaction and a polished user interface.

<figure><img src="/files/VrIE4Grvq45ENqGZsFwi" alt=""><figcaption></figcaption></figure>

**Prefab:** a game object that requirs to have a Text or TextMeshPro UI component

**Input:** the input field to type messages

**Background:** an image component that can fade in fade out depending if room chat is focused or not.

**Container:** a scroll rect view that contains chat entries

### Settings

<figure><img src="/files/KqKGjH7yJ97mlNOmJkPG" alt=""><figcaption></figcaption></figure>

**Activate On Input:** if enabled chat input field can be activated with an specifed input trigger.

**Input Trigger:** the input key to activate the chat.

**Max Lines:** how many lines of messages can the room chat keep

**Max Visible Lines:** how many chat entries stay visible when chat is unfocused/unselected

**Fade Out Start:** how long until starts fading out since the last message received

**Fade Out Duration:** the duratin of the messages fade out

**Background Fade Out Duration:** how long it takes to fade out the backgroud image

**Disable Player When Typing:** if enabled the player movemet will be disabled when typing

**Unseen Messages:** sets a property with the number of unseen messags when chat is unfocused

***

## Floating Text

Floating text serves as an instruction to generate user interface text above a specific target. This feature is commonly utilized for displaying character nameplates, chat bubbles, and other similar elements.

<figure><img src="/files/4svt0gapJTqKt6qiIWbt" alt=""><figcaption></figcaption></figure>

**Target**: the target where the floating text is going to be displayed

**Text:** the text that is going to be displayed in the floating UI

**Prefab:** an optional prefab which you can customize to your needs the only thing needed is a Text or TextMeshPro UI component.

**Offset:** an offset value to display the UI

**Duration:** how long is this UI going to be displayed, mostly useful for bubble chat. If set to 0 it will stay forever.

**Fade Out Time:** the time takes to fade out if duratin is greater than 0

**Color:** a color to tint the text component.

{% hint style="info" %}
The **prefab** is optional but if you don't define it a preconfigured UI will be generated autmatically.
{% endhint %}


# References


# Shutdown Reasons

Describes a list of Reason why the Fusion Runner was Shutdown

* **`Ok:`** means Fusion was Shutdown by request
* **`Error:`** Shutdown was caused by some internal error
* **`IncompatibleConfiguration:`** Raised when the peer tries to Join a Room with a mismatching type between ClientServer Mode and Shared Mode.
* **`ServerInRoom:`** Raised when the local peer started as a Server and tried to join a Room that already has a Server peer.
* **`DisconnectedByPluginLogic:`** Raised when the Peer is disconnected or kicked by a Plugin Logic.
* **`GameClosed:`** Raised when the Game the Peer is trying to Join is Closed
* **`GameNotFound:`** Raised when the Game the Peer is trying to Join does not exist
* **`InvalidRegion:`** Raised when the peer is trying to connect to an unavailable or non-existent Region
* **`GameIdAlreadyExists:`** Raised when a Session with the same name was already created
* **`GameIsFull:`** Raised when a peer is trying to join a Room with already the max capacity of players
* **`InvalidAuthentication:`** Raised when the Authentication Values are invalid
* **`CustomAuthenticationFailed:`** Raised when the Custom Authentication has failed for some other reason
* **`AuthenticationTicketExpired:`** Raised when the Authentication Ticket has expired
* **`PhotonCloudTimeout:`** Timeout on the Connection with the Photon Cloud
* **`AlreadyRunning:`** Raised when Fusion is already running and the StartGame is invoked again
* **`InvalidArguments:`** Raised when any of the StartGame arguments does not meet the requirements
* **`HostMigration:`** Signal this Runner is shutting down because of a Host Migration is about to happen
* **`ConnectionTimeout:`** Connection with a remote server failed by timeout
* **`ConnectionRefused:`** Connection with a remote server failed because it was refused
* **`OperationTimeout:`** The current operation has timed out
* **`OperationCanceled:`** The current operation was canceled


# Guides


# How to test my game

When working a multiplayer game you need to be able to quickly test and iterate over your game, there are few ways to do this.

## Editor & Build

The easiest way to test your multiplayer game is to make a standalone build (PC or Mac) then run the editor and the build at the same time.

{% hint style="info" %}
It's recommeded to make a development build that way you can catch errors easier.
{% endhint %}

## Editor & Clone

This is my favorite way for testing a multiplayer project. You basically have your original project then create a clone out of it the best way to do this is by using by using [**ParrelSync**](https://github.com/VeriorPies/ParrelSync)**.**

[ParrelSync](https://github.com/VeriorPies/ParrelSync) is a Unity editor extension that allows users to test multiplayer gameplay without building the project by having another Unity editor window opened and mirror the changes from the original project.

![Test project changes on clients and server within seconds - both in editor](/files/-MU5ZE1uI6t8Uf7v4a-L)

{% hint style="success" %}
This is the **recommended way** to test your multiplayer game, this allows you to debug and catch errors way easier than any other way.
{% endhint %}


# How to toggle Debug mode

Since few versions of Fusion 2 SDK is comign with debug mode enabled by default to disable it you need to go to **`Tools > Fusion > Toggle Debug Dlls`**

{% hint style="info" %}
Some times after doing this you will need to click on **Run Weaver** in order to apply the updated Dlls
{% endhint %}

<figure><img src="/files/yz67yVSFLMn19hSJal68" alt=""><figcaption></figcaption></figure>

To confirm if you are on **Release** or **Debug** mode you can go to Tools > Network Project Config and the top where it says Fusion Version it should Release or Debug

<figure><img src="/files/l3EnCOHFkmKNlrl0z7R3" alt=""><figcaption></figcaption></figure>


# How to Update Fusion SDK

Before installing a new version is recommended to delete previous SDK without deleting your **NetworkProjectConfig** and **PhotonAppSettings** files, to do this select all folders inside Photon folder except **Resources** inside Fusion folder and delete them.

<figure><img src="/files/Qk310vcPAvXlDhKHfROh" alt=""><figcaption></figcaption></figure>


# Releases

## 1.3.9 (26th October 2025) <a href="#id-139-25th-october-2025" id="id-139-25th-october-2025"></a>

**Fixed**

* Fixed network prop attachment synchronization bug (Thanks Tosh)
* Fixed cached rpc initial invocation bug
* Support for latest Game Creator version 2.18.58

New

* Added default Profanity Filter asset

## 1.3.8 (14th September 2025)

**New**

* Region selection tools — Select Best Region instruction and ping shown in dropdowns
* Tick timers — Stop TickTimer instruction
* NetworkCharacter — Addressable model support for character models
* Register Character Models instruction — Quickly register model prefabs for replication
* Network status & helpers — Conditions for session/internet status plus simple disconnect/shutdown checks
* Session & player data — Last player left, visibility/open checks, user ID and last joined player info
* Chat & authentication — Optional profanity filter and custom authentication; centralized auth settings
* Fail‑Safe system — Configurable protections against common runtime issues
* Error messages library — Curated, editable network message texts
* WebGL — Clipboard copy support
* Addressables

**Enhanced**

* Scene loading — Smoother transitions with clearer Start/Done events and fewer allocations
* Region selection — Auto‑best option, cleaned lists, improved ping detection and display
* Networking stability — Safer authority guards
* Pooling options — Can disable pooling per module; increased capacities where needed
* UI/UX — More reliable room chat, lobby control activations, clearer shutdown reasons and error messages
* NetworkSceneManager — Better orchestration for multi‑scene management

**Changed**

* Authority handling — Automatic ownership transfer when overriding authority; request authority for orphaned objects
* Spawning — Aligned Spawn and SpawnAsync behavior

**Fixed**

* Stability — Many null‑reference protections and safer error paths
* Scene, spawn & lifecycle — Reliable Spawned/Despawned events and player spawn/despawn; regressions addressed in NetworkSceneManager
* Chat & lobby — Robust initialization even if prefabs or addressables aren’t loaded; authentication method support
* Regions & ping — Edge‑case handling and invalid values; dropdowns show accurate ping
* WebGL & platform — Loading and Network Object Provider behavior; clipboard follow‑ups; compile/build fixes
* Authority & state — Correct dead‑state sync and facing on authority change; guard checks
* Addressables & errors — Better shutdown reason retrieval; auto‑release of handles; safer StartGameAsync and related flows

## 1.2.7 (29th December 2024)

* Support for latest Photon Fusion SDK 2.0.4
* Restructured the Start Game instruction to support loading scenes by string, enabling the use of scenes from Addressable bundles.
* The master client will now automatically take network authority over objects (with “Allow State Authority Override” enabled) when players leave the session.
* RPCs no longer require a player to be instantiated in order to call them
* **Added** an option in Fusion settings to specify a custom runner prefab. This is useful for cases where customization is needed, such as integrating the Fusion Physics addon.
* **Added** an option in Fusion settings to customize the default pool size for network-spawned objects.
* **Added** a new property to retrieve the network-synchronized input direction value from a character.
* **Added** new numeric properties to return the network simulation time, local render time, and the last server tick.
* **Fixed** an issue with Spawned and Despawned network object events
* **Fixed** an issue where the Local Player property did not return the correct object.
* **Fixed** an issue where the Player Username property did not return the correct value.
* **Fixed** an issue where RoomChat failed to initialize properly in certain cases.
* **Fixed** an issue where the NavMeshAgent failed to initialize correctly after being spawned in certain cases.
* **Fixed** multiple issues affecting NPC characters.
* Username is no longer stored in PlayerPrefs
* Updated demos

## 1.1.6 (30th October 2024)

* Fixed cached rpcs issue being interrupted by model change calls
* Fixed an error in NetworkCharacterEditor
* Fixed an issue in sub modules version manager
* Updated Fusion Uninstall to prevent removing sub modules

## 1.1.5 (21th October 2024)

* Unity 6 support
* Game Creator 2.51.17 support
* Added new NPC demo scene
* Added version in manager in settings
* Deactivate nested network objects instead of destroying
* Internal changes to prepare for upcoming sub-modules
* Bug fixes in NetworkCharacter to make NPCs work properly
* Added is master client bool and string properties
* Player ping is now exposed over the network
* Updated Network Character inspector at runtime

## 1.0.4 (1st October 2024)

* Fixed an issue with Single player mode
* Added single player demo
* Reverted a change that caused an order of events issue with cached RPCs
* Improved bone finding for network attachment props

## 1.0.3 (26th September 2024)

* Support for latest Fusion 2.0.3
* New Name Variables demo scene
* Reduced arrays and dictionaries limit capacity to reduce pre-allocated heap
* Added help urls to components
* Fixed an error when using attach props without adding them to fusion
* Fix for variables not replicating boolean states
* Fixed an issue in TickTimer scene
* Name Variables can now sync NetworkPrefabRef type
* List Variables now support vector 3 and NetworkPrefabRef
* Renamed Despawn instruction title
* Fixed an issue where fusion was deactivating non instantiated network objects instead of destroying them

## 1.0.2 (23th August 2024)

* Support for latest Fusion 2.0.2
* Improved attachment synchronization to work with different rigs
* Added setters for Network Prefab Ref
* Added new Set Network Prefab Ref instruction
* Added new is scene authority condition
* Added new load and unload scenes instructions for fusion
* Fixed some minor issues on demo scenes

## 1.0.1 (19th August 2024)

* **Breaking Change:** Fusion Character Controller Directional is no longer required to synchronize characters; only attaching the Network Character component is required.
* **New:** all other controller types like navmesh, rigidbody, tank, etc are now supported
* **Added** option to select Network Prefab Ref from variables in Spawn Player instruction
* **New** navmesh demo
* **Added** all demo scenes to map selection in lobby
* **Fixed** issue with Fusion Character Controller not setting up Network Transform properly
* **Renamed** component menu path on some network components
* **Renamed** disconnect game and lobby to shutdown game and shutdown lobby to avoid confussion
* **Added** max width to default chat bubble
* Updated all demo scenes

## 1.0.0 (19th August 2024)

First release.


# Fusion Factions

Overview

The **Fusion Factions** submodule integrates Fusion 2 with the Factions module, ensuring that all faction-related data is synchronized across the network.\
This includes:

* Synchronizing member faction points
* Joined factions
* Relationships
* And variables.

{% hint style="success" %}
[**Get Fusion Factions on the Unity Asset Store →**](https://www.ninjutsugames.com/go/fusion-factions?src=docs_fusion_factions_overview)
{% endhint %}

## Requirements

Install [**Game Creator 2**](https://www.ninjutsugames.com/go/game-creator-2?src=docs_fusion_factions_requirement_gc2), [**Photon Fusion**](https://www.ninjutsugames.com/go/photon-fusion?src=docs_fusion_factions_requirement_sdk), [**Fusion**](https://www.ninjutsugames.com/go/fusion?src=docs_fusion_factions_requirement_core), and [**Factions**](https://www.ninjutsugames.com/go/factions?src=docs_fusion_factions_requirement_factions) before installing Fusion Factions.

## Setup

If you haven't get the **Fusion Factions** sub-module, head to the Asset Store product page and follow the steps to get a copy of this module.

Once you have bought it, click on **Window → Package Manager** to reveal a window with all your available assets.

Type in the little search field the name of this package and it will prompt you to download and install the latest stable version. Follow the steps and wait till Unity finishes compiling your project.

{% hint style="success" %}
This package will add 2 new network components, **MemberNetwork** and **FactionNetwork**
{% endhint %}

## Member Network

Synchronizes member faction points and current joined factions across the network.

<div align="left"><figure><img src="/files/6fLxhmjRHEvclWAveCSk" alt="" width="375"><figcaption></figcaption></figure></div>

## Faction Network

Synchronizes faction relationships and variables through the network.

<div align="left"><figure><img src="/files/RfrAoa9ubcbuyLRXrinm" alt=""><figcaption></figcaption></figure></div>


# Releases

## 1.0.1 (31th October 2024)

* Fixed an issue with the sub module path

## 1.0.0 (23th October 2024)

* First release


# Fusion Stats

Overview

The **Fusion Stats** submodule integrates Fusion 2 with the Stats 2 module, ensuring that all character traits data is synchronized across the network.

\
This includes:

* Stats
* Attributes
* Status Effects
* Modifiers

{% hint style="success" %}
[**Get Fusion Stats on the Unity Asset Store →**](https://www.ninjutsugames.com/go/fusion-stats?src=docs_fusion_stats_overview)
{% endhint %}

## Requirements

Install [**Game Creator 2**](https://www.ninjutsugames.com/go/game-creator-2?src=docs_fusion_stats_requirement_gc2), [**Photon Fusion**](https://www.ninjutsugames.com/go/photon-fusion?src=docs_fusion_stats_requirement_sdk), [**Fusion**](https://www.ninjutsugames.com/go/fusion?src=docs_fusion_stats_requirement_core), and [**Stats 2**](https://www.ninjutsugames.com/go/stats-2?src=docs_fusion_stats_requirement_stats) before installing Fusion Stats.

## Setup

If you haven't get the **Fusion Stats** sub-module, head to the Asset Store product page and follow the steps to get a copy of this module.

Once you have bought it, click on **Window → Package Manager** to reveal a window with all your available assets.

Type in the little search field the name of this package and it will prompt you to download and install the latest stable version. Follow the steps and wait till Unity finishes compiling your project.

{% hint style="success" %}
This package will add one new network component called **TraitsNetwork**
{% endhint %}

## Traits Network

Synchronizes traits stats, attributes, status effects, modifiers across the network.

<figure><img src="/files/IsfBNJsf51vnKnWe187F" alt=""><figcaption></figcaption></figure>


# Releases

## 1.0.0 (15th December 2024)

* First Release


# Fusion Inventory

Coming soon.


# Releases

## 1.0.0

* Coming soon


# Fusion Abilities

Coming soon.


# Releases

## 1.0.0

* Coming soon


# Fusion Melee

Coming soon.


# Releases

## 1.0.0

* Coming soon


# Fusion Shooter

Coming soon.


# Releases

## 1.0.0

* Coming soon


# Factions

## Overview

The **Factions** module for **Game Creator 2** offers a comprehensive system for managing factions, reputation, and dynamic relationships within your game.

{% embed url="<https://youtu.be/xgJqFDh_ias>" fullWidth="false" %}

{% hint style="success" %}
Play the [**Demo**](https://hjupter.itch.io/factions) now!
{% endhint %}

{% hint style="success" %}
[**Get Factions on the Unity Asset Store →**](https://www.ninjutsugames.com/go/factions?src=docs_factions_overview)
{% endhint %}

## Key features <a href="#key-features" id="key-features"></a>

* Easy faction setup and management
* Dynamic reputation system
* Faction variables
* Event-driven system for faction interactions
* Full multiplayer support with Photon Unity Networking
* Built-in Scoreboard and UI components
* Visual scripting integration with Game Creator 2

{% hint style="success" %}
All actions and conditions are compatible with other Game Creator modules.
{% endhint %}


# Setup

Welcome to getting started with the Factions module. In this section, you’ll learn how to install this module and get started with the examples it comes with.

## Prepare your Project

Before installing the **Factions** module, you’ll need to either create a new Unity project or open an existing one.

{% hint style="warning" %}
It is important to note that [**Game Creator 2**](https://www.ninjutsugames.com/go/game-creator-2?src=docs_factions_setup_game_creator) should be present before attempting to install any module.
{% endhint %}

## Install the Factions module

If you haven't purchased the module, [**get Factions on the Unity Asset Store →**](https://www.ninjutsugames.com/go/factions?src=docs_factions_setup_module), then follow the steps below to install it.

Once you have bought it, click on **Window → Package Manager** to reveal a window with all your available assets.

Type in the little search field the name of this package and it will prompt you to download and install the latest stable version. Follow the steps and wait till Unity finishes compiling your project.

## Examples

We highly recommend checking the examples that come with the **Factions** module. To install them, click on the *Game Creator* dropdown from the top toolbar and then the *Install* option.

The **Installer** window will appear and you'll be able to manage all examples and template assets you have in your project.

* **Examples**: A collection of scenes with different use-case scenarios
* **UI**: A bundle of common user interface elements
* **Factions:** A collection of common RPG factions
* **Dialogue Examples:** A small demo showcasing Factions integrated with Dialogue
* **Quests Examples:** A small demo showcasing Factions integrated with Quests

<figure><img src="/files/0h4w10pSlHdKpCdGl2nT" alt=""><figcaption></figcaption></figure>

{% hint style="success" %}
Clicking on the **Examples** install button will install all dependencies automatically.
{% endhint %}

Once you have the examples installed, click on the *Select* button or navigate to `Plugins/GameCreator/Installs/Factions.Examples/`.

<figure><img src="/files/Eajy84sMHPnlUXrveLFZ" alt=""><figcaption></figcaption></figure>


# Faction Asset

## Overview

The **Faction** asset defines the various factions within your game. It includes settings for reputation thresholds, relationships with other factions, and custom variables.

## Creating a New Faction Asset

To create a new **Faction** asset, right-click on the Project Panel and select Create → Game Creator → Factions → Faction.

<div align="left"><figure><img src="/files/sL2NEbBCkrSTX7gdpHXh" alt="" width="375"><figcaption></figcaption></figure></div>

## Inspector Overview

The **Faction** asset has several distinct sections, each allowing you to configure different aspects of the faction.

The top section includes general information about the ***Faction*** such as its **Name** or a **Description** (if any). It also optionally allows to determine a **Color** and a **Sprite** image used in [UI](/game-creator-2/factions/user-interface).

The **Type** field determines whether the ***Faction*** is a *hidden* faction, or a *normal* one.

<div align="left"><figure><img src="/files/AOau6Rg4uE3fOAJI2JVb" alt="" width="375"><figcaption></figcaption></figure></div>

{% hint style="info" %}
Hidden factions can be hidden from UI elements and are useful for setting up factions that should not be displayed to the user. For example, a player or secret faction.
{% endhint %}

The **Sorting Order** determines the priority of the ***Faction*** compared to the rest, when being displayed as a list on UI elements. A ***Faction*** with a higher value will be displayed above other ***Faction*** assets.

The **ID** is a unique identifier that distinguishes a ***Faction*** from others.

{% hint style="warning" %}
If there are two *Faction* assets with the same **ID** value, an error message will appear above. To resolve it, click on any of the fields and it will reveal a button that regenerates the current value with a unique one.
{% endhint %}

## Reputation Thresholds

The Reputation Thresholds section allows you to define how reputation points translate into faction stances.

{% hint style="info" %}
Reputation points can be disabled in a Faction by disabling "Use Reputation"
{% endhint %}

Each stance is defined by a color and a point threshold, making it easy to visualize the current reputation level in the game.

<div align="left"><figure><img src="/files/NWZrJXAj4JJbfs0p3iva" alt="" width="375"><figcaption></figcaption></figure></div>

{% hint style="success" %}
Negative values can also be utilized for reputation thresholds.
{% endhint %}

## Faction Relationships

This section allows you to define the default relationships this faction has with other factions.

<div align="left"><figure><img src="/files/xmwm6ONaNTF8eE2BI8sk" alt="" width="375"><figcaption></figcaption></figure></div>

{% hint style="success" %}
You can click on each circle to change **relationship** towards the specific **Faction**
{% endhint %}

## Faction Variables

Custom variables can be defined on factions. These variables can be used in gameplay to store faction-specific data.

Faction Variables allow you to define custom data specific to each faction. These variables work similarly to Global Name Variables, but with a **key distinction**: all factions have the same set of variables, but each faction can hold different values for these variables.

<div align="left"><figure><img src="/files/zHIkdHmr09i8bBG66bUU" alt="" width="375"><figcaption></figcaption></figure></div>

{% hint style="success" %}
For example, if you define a variable called resourceLevel, every faction will have this variable, but the resourceLevel value can be different for each faction. This allows you to track and manage faction-specific data dynamically.
{% endhint %}

By using Faction Variables, you can create a rich, dynamic environment where each faction’s unique state can influence the overall gameplay experience.

## Save & Load

**Variables** and **Relationships** can be saved between play sessions to later be restored when loading a game. Disabling the *save* option will make all variables keep the initial value as their starting value, even after loading a previously saved game.

<figure><img src="/files/QL9oho1zMLbrL00eyA8z" alt=""><figcaption></figcaption></figure>


# Settings Editor

## Faction Settings Editor

The Faction Settings Editor is the central hub for managing all faction relationships and statuses within your game. It provides a comprehensive interface for defining and visualizing how different factions interact with each other.

<figure><img src="/files/oIgRmoDCJjriHnMCa97v" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
**Faction relationships** in this system are inherently **two-way**, meaning that each faction’s stance towards another can differ.
{% endhint %}

{% hint style="success" %}
**For example**, while the “Humans” faction might view the “Orcs” as hostile, the “Orcs” might view the “Humans” as neutral.\
\
This dynamic allows for complex and realistic interactions where each faction independently determines its stance towards every other faction.\
\
The relationships matrix visually represents these two-way dynamics, making it easy to understand and manage the intricate web of inter-faction relationships in your game.
{% endhint %}

## Faction Statuses

* **Key**: This field allows you to define the name of the faction status, such as Hostile, Neutral, Friendly, or any custom status like Honored.
* **Color**: Each status is associated with a color for easy visualization and differentiation.
* **Points Required**: This defines the reputation points needed for an entity to reach a specific status with a faction.

## Faction Relationships Matrix

The relationships matrix is a visual representation of how each faction perceives the other factions. It uses the defined statuses to show these relationships.

{% hint style="success" %}
Select each circle to modify the relationship status between factions. These adjustments will also be applied to each Faction asset accordingly.
{% endhint %}

\\


# Member

The Member component is essential for integrating any object or character into the Faction system. By adding this component, you enable the object or character to join or leave factions dynamically.

{% hint style="info" %}
It is usually attached to the **Character** object so it's easy to access. However, you can decide to attach it to some other object or even have multiple characters.
{% endhint %}

## Overview

The Member component allows an object or character to:

* Join multiple factions at the start or dynamically during runtime.
* View and manage affiliations with various factions.
* Display status towards the player if the selected member is not the player.
* Handle reputation points if enabled for specific factions.

<div align="left"><figure><img src="/files/Z8r2OYKFp2sT2kJjINRR" alt=""><figcaption></figcaption></figure></div>

## Handling Reputation Points

If reputation points are enabled for a faction, the member’s actions can influence their status within that faction.

{% hint style="info" %}
Use the **Ignore Reputation Points** checkbox to exclude reputation points from affecting the member’s faction status.
{% endhint %}

## Live Debugging

### Active Factions

Displays the list of factions the member is currently part of.

Shows the current status (e.g., Friendly, Neutral, Hostile) and allows leaving the faction.

### Other Factions

Lists all other available factions.

Shows the relationship status and provides options to join the factions.

### Status Towards Player

If the selected member is not the player, the component will display the status of this member towards the player.

This helps in understanding the relationship dynamics from the member’s perspective.

<figure><img src="/files/mcKQDsFDJjKNrf4Dbngv" alt=""><figcaption></figcaption></figure>


# Memory

The **Faction Memory** component integrates with the Game Creator 2 Save & Load system to persistently save and load the faction-related data for any object, character, or player. This component ensures that all member joined factions, reputation points, and statuses are retained across game sessions, enhancing the continuity and immersion of your game’s faction system.

<figure><img src="/files/vggvRHpgUzE2jwhGXqat" alt=""><figcaption></figcaption></figure>

{% hint style="success" %}
The Faction Memory component works similarly to other memory components (e.g., Position, Rotation, Scale) within Game Creator 2. By adding this component to an object or character, you enable the game to remember and restore their faction memberships and related data.
{% endhint %}


# Visual Scripting

The **Factions** module symbiotically works with **Game Creator** and the rest of its modules using its visual scripting tools.

{% content-ref url="/pages/HOMpkgJkA5mF2BXcdNpB" %}
[Conditions](/game-creator-2/factions/visual-scripting/conditions)
{% endcontent-ref %}

{% content-ref url="/pages/nU4d7uU9kaxcX3tI62F1" %}
[Events](/game-creator-2/factions/visual-scripting/events)
{% endcontent-ref %}

{% content-ref url="/pages/OC2KSCxmd0V4d86xNr9H" %}
[Instructions](/game-creator-2/factions/visual-scripting/instructions)
{% endcontent-ref %}

{% content-ref url="/pages/r3ey3uOBhrGjAEIF1ttN" %}
[Properties](/game-creator-2/factions/visual-scripting/properties)
{% endcontent-ref %}

Each scripting node allows other modules to use any **Factions** feature.


# Conditions

<figure><img src="/files/eqE13FiIveHlOkzjeaZ3" alt=""><figcaption></figcaption></figure>


# Events

<figure><img src="/files/ghSdbvMkyMVPHqcci5fq" alt=""><figcaption></figcaption></figure>


# Instructions

<figure><img src="/files/hVtiVYASOW6LTLcJrOMH" alt=""><figcaption></figcaption></figure>


# Properties

## String Properties

<div align="left"><figure><img src="/files/9iIRdVlyTZ2qOy4gvxeZ" alt="" width="375"><figcaption></figcaption></figure></div>

## Number Properties

<div align="left"><figure><img src="/files/gQdObbn1bhxBSkbarTkf" alt="" width="375"><figcaption></figcaption></figure></div>

## Color Properties

<div align="left"><figure><img src="/files/md3FhvvPDWFTSYI61Q23" alt="" width="375"><figcaption></figcaption></figure></div>

## Faction Properties

<div align="left"><figure><img src="/files/MfJz0hv86jxumbzjoPc8" alt="" width="375"><figcaption></figcaption></figure></div>

## Sprite Properties

<div align="left"><figure><img src="/files/eHoKm40YoGjoIH1FJFg9" alt="" width="375"><figcaption></figcaption></figure></div>


# User Interface

The **Factions** module comes with a collection of components designed to streamline the creation of UI windows and elements.

All examples that come with the module have been created with them and are flexible to accommodate any type of window.

## Factions List UI

This is one of the most important components and allows to display a list of **Factions** in a list fashion.

<figure><img src="/files/rx5cidFglgeR6C6u7Tzp" alt=""><figcaption></figcaption></figure>

The **Member** field determines which component the factions are taken from.

The following fields act as filters to display those factions.

* The **Show** dropdown allows to display only factions that are in a particular state. For example, display only those that the Member is in or not.
* The **Show Hidden** toggle determines whether hidden factions should be displayed or not.
* The **Filter** dropdown allows to define whether to only display those factions that are present in a Global or Local List Variable.

The **Content** field defines the `Rect Transform` where each prefab instance will be instantiated, for every visible faction.

{% hint style="info" %}
The **Content** value should contain an auto-layout component, such as `Vertical Layout Group`, `Horizontal Layout Group` or `Grid Layout Group`.
{% endhint %}

The **Prefab** is the prefab instantiated inside the *Content*. It must contain a **Faction UI** component, which is automatically configured by its parent.

## Faction List UI Tab

The Faction List UI Tab component is typically used to filter and present factions dynamically within the Faction List UI.

<figure><img src="/files/TrAMYKTeIvbPUy0OEyWZ" alt=""><figcaption></figcaption></figure>

## Faction UI

This component is used in tandem with the **Factions List UI** to display a faction based on a set of rules and filters.

<figure><img src="/files/HvJbb9cFsFuODktSkc5y" alt=""><figcaption></figcaption></figure>

The **Title**, **Description**, **Member Count**, **Color** and **Sprite** fields are all optional and reference the indexed faction's homonymous values.

The **Reputation Elements** dynamically display the faction’s reputation status, points, and progress. This is essential for showing the player’s standing with different factions and how close they are to changing their reputation status.

The **Active Elements** section defines a set of optional game objects that are activated/deactivated according to different conditions.

The **Interactive** elements allow to define different types of interactions performed by the player.

For example, the `Button Leave` field instructs a button to leave a faction when clicked.

The `Select Faction` field allows to define a selection element as a button to select this particular faction.

## Selection UI

Upon selecting a faction, any Faction UI component with the *Selection* keyword will be automatically updated.

<div align="left"><figure><img src="/files/fwzRwkXrKB3fGRKyHW5C" alt="" width="375"><figcaption></figcaption></figure></div>

## Scoreboard UI

The Scoreboard UI component is used to display the members of a faction, sorted and presented in a specified format. This component can dynamically update to show the current standings or scores of faction members, based on various criteria.

{% hint style="success" %}
The Scoreboard UI component provides a structured interface to display a list of faction members, sorted and formatted according to the specified settings. This is useful for creating leaderboards, rankings, or any other type of member listing within a faction.
{% endhint %}

<figure><img src="/files/VLYjafCtzFEkD0x25BlV" alt=""><figcaption></figcaption></figure>

The **Faction** field determines which faction’s members to display. If set to “Any”, it will display members from all factions. If set to “Specific”, you can choose a particular faction.

The **Content** field is UI container that will hold the instantiated member items.

The **prefab** to be used for each member item in the scoreboard. This prefab should include all the necessary UI elements to display member information.

The **Sort Direction** field determines the order in which members are displayed based on the sort field index.

The **Sort Index** specify the index of the member attribute to sort by. This allows for flexibility in sorting by different criteria, such as points, rank, or other custom fields.

{% hint style="success" %}
By utilizing the Scoreboard UI component, you can create a dynamic and interactive leaderboard or member listing for your factions, enhancing the competitive and social aspects of your game.
{% endhint %}

## Scoreboard Item UI

The Scoreboard Item UI component is designed to represent individual entries within the scoreboard, displaying various attributes of faction members.

The **alternate background** option allows you to set an alternate background image for the scoreboard item, which can help distinguish between different rows for better readability.

### The fields

Fields can be customized to display specific data of types **string** or **number**.

The **Text** field is the component that displays the data

**Use Format** enables the formatting feature for the associated text or number field.

{% hint style="info" %}
**Percentage Formatting**\
Use `{0:P}` to convert 0.99 to 99%.

**Currency Formatting**\
Use `{0:C}` to convert 1000 to $1,000.00.

**Number Formatting**\
Use `{0:N}` to convert 1000 to 1,000.
{% endhint %}

**Use Color** enables the option to apply color to the field using properties

<figure><img src="/files/WuHawWC8K9OvT8TZMcEv" alt=""><figcaption><p>This component can be customized to show different fields such as player names, scores, and other relevant data.</p></figcaption></figure>

## Scoreboard UI Tab

The Scoreboard UI Tab component handles the sorting functionality for the scoreboard. It includes options for sorting direction and the index of the field to sort by.

<figure><img src="/files/hRNdUv0dV6X7DKjRCVf9" alt=""><figcaption></figcaption></figure>

**Scoreboard UI:** The UI component that displays the scoreboard.

**Sort Direction:** Defines whether the sorting is ascending or descending.

**Sort Index:** Specifies the field used for sorting.

**Active Index and Direction Arrow:** Indicates the current sorting field and direction, providing a visual cue for users.


# Releases

## 1.1.3 (31th December 2024)

* Added instruction to collect target candidates by status and distance
* Added a new instruction to add target candidates from a specified faction
* Fixed a null error that occurred when comparing member status in certain cases
* Fixed an issue where the Set Faction property did not correctly reference the variable

## 1.1.2 (18th October 2024)

* Unity 6 support
* Support for latest Game Creator 2.17.51
* Added version manager in settings
* Fixed an issue in Collect Faction Members instructions
* Fixed a bug in settings inspector

## 1.0.1

* Support for latest Game Creator 2.16.50
* Updated demos

## 1.0.0 (17th June 2024)

* First release.


# Photon Factions

## Overview

The **Photon Factions** submodule integrates Photon Unity Networking with the Factions module, ensuring that all faction-related data is synchronized across the network.\
This includes:

* Synchronizing member faction points
* Joined factions
* Relationships
* And variables.

{% hint style="success" %}
[**Get Photon Factions on the Unity Asset Store →**](https://www.ninjutsugames.com/go/photon-factions?src=docs_photon_factions_overview)
{% endhint %}

## Requirements

Install [**Game Creator 2**](https://www.ninjutsugames.com/go/game-creator-2?src=docs_photon_factions_requirement_gc2), [**PUN 2**](https://www.ninjutsugames.com/go/photon-pun-2?src=docs_photon_factions_requirement_pun), [**Photon Module 2**](https://www.ninjutsugames.com/go/photon-module-2?src=docs_photon_factions_requirement_core), and [**Factions**](https://www.ninjutsugames.com/go/factions?src=docs_photon_factions_requirement_factions) before installing Photon Factions.

## Setup

Once you have the package downloaded in your project just open **Game Creator Install** window and select Photon > Factions sub module and install it.

<figure><img src="/files/yKca7rHMq643AyXTn96m" alt=""><figcaption></figcaption></figure>

{% hint style="success" %}
This package will add 2 new network components, **MemberNetwork** and **FactionNetwork**
{% endhint %}

## Member Network

Synchronizes member faction points and current joined factions across the network.

<div align="left"><figure><img src="/files/6fLxhmjRHEvclWAveCSk" alt="" width="375"><figcaption></figcaption></figure></div>

## Faction Network

Synchronizes faction relationships and variables through the network.

<div align="left"><figure><img src="/files/RfrAoa9ubcbuyLRXrinm" alt=""><figcaption></figcaption></figure></div>


# Coop

Local multiplayer for Game Creator 2

Coming soon 2024


# Loot Locker

The ultimate backend system for Game Creator 2

This module integrates [LootLocker](https://www.lootlocker.com) backend system with Game Creator 2

{% embed url="<https://youtu.be/HJ-1H5AlbzU>" %}

{% hint style="success" %}
[**Get LootLocker for Game Creator 2 on the Unity Asset Store →**](https://www.ninjutsugames.com/go/loot-locker?src=docs_loot_locker_overview)
{% endhint %}

## Key Features

* Leaderboards
* Load Save (Built-in integration with Game Creator 2's LoadSave system)
* Progressions (Character levels, professions etc)
* Messages (in-game news, notifications)
* Replenish System (Server time based system to replenish values and offline earnings)
* Authentication (Google, Apple, Email, Guest, Steam and more)
* Player Storage
* Player Name
* Date Time System (Use date time as variables anywhere)
* Triggers (Add whatever triggers you want to, then reward players however you see fit.)

## Coming Soon

* Heroes & Classes (Rogue. Tank. Omniknight. Define the heroes and classes that players can play, their attributes, and what they can equip or store in their inventory.)
* Leaderboards meta data
* Friends and Clan system
* Built-in integration with official modules Inventory, Quest and Stats
* Economy System
* Universal Accounts
* Account linking
* In-Game Stores
* User Generated Content
* Currencies
* Battle Passes
* Achievements


# Getting Started

Getting started with LootLocker couldn't be easier. Follow these five simple steps and you'll be up and running in no time!

### 1. Create a Free Account

To create your free LootLocker account, visit the [sign-up page on the LootLocker website](https://lootlocker.com/sign-up). In this form you can provide your name, company name, email address, and set a password. Confirm that you agree to the Terms of Service and Privacy Policy, and click Create Free Account.

### 2. Create a New Game

Once you've created and verified your account, you'll next want to create a new game within LootLocker through our [Web Console](https://console.lootlocker.com/). If you've already created a game and want to create a new one, simply click New Game in the My Games panel in your game dashboard.

### 3. Install & Configure the SDK

The SDK can be downloaded through the Unity Asset Store, from the LootLocker Github repository release page, or installed directly using the Unity Package Manager.

* [Unity Asset Store](https://www.ninjutsugames.com/go/lootlocker-sdk?src=docs_lootlocker_getting_started_sdk)
* [Github Repository](https://github.com/LootLocker/unity-sdk) (Recommended)

{% hint style="info" %}
Follow the guide on the link below to install via Package Manager
{% endhint %}

### 4. Configure the SDK

You can follow this guide to configure LootLocker SDK <https://docs.lootlocker.com/the-basics/unity-quick-start/install-and-configure-the-sdk>

### 5. Install the Module

If you do not own it yet, [**get LootLocker for Game Creator 2 on the Unity Asset Store →**](https://www.ninjutsugames.com/go/loot-locker?src=docs_loot_locker_getting_started_module).

After importing the LootLocker module, head to the Game Creator Install window and install the Core package.

{% hint style="danger" %}
This module requires [**Game Creator 2**](https://www.ninjutsugames.com/go/game-creator-2?src=docs_loot_locker_getting_started_game_creator) and won't work without it. Don't attempt to extract the package inside the Plugins/ folder as it will throw some errors.
{% endhint %}

<figure><img src="/files/Sfo27NJCbRA1vxdSdU1g" alt=""><figcaption></figcaption></figure>


# Authentication

LootLocker supports different types of authentication methods. You'll want to select the best method depending on your game and target platforms.

When starting the game, you first have to authenticate the player with LootLocker.

Depending on which platform the game is running on you have different options for registering a session.

{% hint style="info" %}
Click [**here**](https://docs.lootlocker.com/players/authentication) to learn more about authentication methods in LootLocker
{% endhint %}

<table data-card-size="large" data-view="cards"><thead><tr><th></th><th></th><th data-hidden></th><th data-hidden data-card-cover data-type="files"></th><th data-hidden data-card-target data-type="content-ref"></th></tr></thead><tbody><tr><td><strong>Guest Login</strong></td><td>Skip the login screen and let players jump straight into the game. Just assign them an ID from the game instead.</td><td></td><td></td><td><a href="/pages/PmE5Og7SaVpE0oPnVB4s">/pages/PmE5Og7SaVpE0oPnVB4s</a></td></tr><tr><td><strong>White Label</strong></td><td>Create a custom login screen where players register their username and email address for one or all of your games</td><td></td><td></td><td><a href="/pages/RFYaISh5sRlh3qUfM3VB">/pages/RFYaISh5sRlh3qUfM3VB</a></td></tr><tr><td><strong>Google Play</strong></td><td>Authentica</td><td></td><td></td><td><a href="/pages/J7E5LHSXCQv6NQgfYXeG">/pages/J7E5LHSXCQv6NQgfYXeG</a></td></tr><tr><td></td><td><strong>Steam</strong></td><td></td><td></td><td><a href="/pages/coHa4WM2dDcxTWWqCQ6D">/pages/coHa4WM2dDcxTWWqCQ6D</a></td></tr><tr><td><strong>Apple Sign In</strong></td><td></td><td></td><td></td><td><a href="/pages/YCU9vv977SbtG9Ho1A1o">/pages/YCU9vv977SbtG9Ho1A1o</a></td></tr></tbody></table>


# Guest

The fastest and easiest way to create and identify a user account

## Setup

To enable **Guest** accounts you have to enable it in [**LootLocker's**](https://console.lootlocker.com/settings/platforms/guest) platforms dashboard

![](/files/ZYFdbRtP7vHCaBUVM16x)

Head to the guest login section, enable it and click save.

![](/files/4kKyDSKgY9ftCnMffoKQ)

## How to Use

A guest session can be started by using the **Start Guest Session** instruction

<figure><img src="/files/gqhojtnIKTyKPzvIVTtu" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
Any type of string can be used as identifier
{% endhint %}


# White Label

## Setup

To enable **White Label** accounts you have to enable it in [**LootLocker's**](https://console.lootlocker.com/settings/platforms/guest) platforms dashboard

![](/files/VUb4JtE6kh2OA3RAei0i)

Head to the white label login section, enable it and click save.

![](/files/yIh0GOBmWvbj9yfwHGiE)

## Login

To authenticate with this method you can use the **White Label Login and Start Session** instruction.

Here you need to pass in an **email**, **password** and **remember** boolean

<figure><img src="/files/Pm6BX0MIDlkmJEO6okj0" alt=""><figcaption></figcaption></figure>

## Signup

To signup use the **White Label Signup** instruction.

You need to pass in an **email** or **username** and **password**, if **Verify Email** is on it will if the passed in email is correct.

<figure><img src="/files/18rqEuvnZKvvFXydJcij" alt=""><figcaption></figcaption></figure>

## Account Recovery

If player forgot the password you can use the **White Label Request Password** instruction.

Only pass the **email** address and this will send an email to user with a link change the password.

<figure><img src="/files/I6fyJCus5uzhSGDvz3IM" alt=""><figcaption></figcaption></figure>

## Account Verification

If you account verification enabled players will get an email to verify their account but if for any reason they need to request verification again you can use the **White Label Request Verification** instruction.

<figure><img src="/files/R0Zp0VSBeOIIT11tnxWZ" alt=""><figcaption></figcaption></figure>


# Google

Authenticate your players using Google and register a session for them on the LootLocker backend.

{% hint style="warning" %}
The Google platform needs to be enabled and configured in the Web Console before it can be used in your game.
{% endhint %}

## Installation

Open up Game Creator install window, select Google Sign In and install it

<figure><img src="/files/EdmjGOrCG2i4lpSZxHSm" alt=""><figcaption></figcaption></figure>

## Loot Locker Dashboard Configuration

To start using Sign in with Google we first need to configure LootLocker integration in the [platform settings](https://console.lootlocker.com/settings/platforms/google_sign_in).

<figure><img src="/files/7kp4t1WmNZJBmFuO1Io9" alt=""><figcaption></figcaption></figure>

**Client ID**

Client ID can be retrieved from the [Google Dev Console](https://console.cloud.google.com/apis/credentials). If you don't have an OAuth2 Client ID, you will have to create one.

## Game Creator Configuration

Fill in **Client Id** and **Client Secret** depending on the platform you need.

<figure><img src="/files/l5W9H72AswNWRdFm0Zjs" alt=""><figcaption></figcaption></figure>


# Steam


# Apple Sign In


# Sessions


# Save Load

LootLocker module has built-in integration with Game Creator 2 Save & Load system

This module can use LootLocker files system to store all data from any module.

{% hint style="info" %}
Click [here](https://docs.gamecreator.io/gamecreator/advanced/save-load-game/) learn mode about Game Creator's 2 Save & Load system
{% endhint %}

## Setup

It is pretty simple to set this up, just go to Game Creator > Settings > General and change the saving system to LootLocker Storage

<figure><img src="/files/YuNITXtzYRTPR8u2wgp2" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
In order to be able to save & load using LootLocker you need be [authenticated](/game-creator-2/loot-locker/authentication).
{% endhint %}

## Trigger

Once a session is started saved data is loaded automatically and optionally you can use **On Save Game Loaded** to handle any use case you need.

<figure><img src="/files/0VKpeyhlzREZc15LDh9D" alt=""><figcaption></figcaption></figure>


# Players


# Player Storage


# Names


# Leaderboards

To use leaderboards you need to create in LootLocker's dashboard first, you can follow this [**guide**](https://docs.lootlocker.com/game-systems/leaderboards/create-a-leaderboard) to do it.

{% hint style="info" %}
To learn more about Leaderboards you can go to LootLocker's documentation [**here**](https://docs.lootlocker.com/game-systems/leaderboards)
{% endhint %}

<figure><img src="/files/CcASJKBYm3KGvdHrHk70" alt=""><figcaption></figcaption></figure>

## UI

To show a UI you have to use the **Loot Locker Leaderboard UI** component

<figure><img src="/files/qPWQABjNglvJkFXhQBqv" alt=""><figcaption></figcaption></figure>

<table><thead><tr><th width="201">Parameter</th><th>Description</th></tr></thead><tbody><tr><td>Leaderboard Id</td><td>Key of the leaderboard to get entries for</td></tr><tr><td>Count</td><td>How many entries to get</td></tr><tr><td>After</td><td>How many after the last entry to receive</td></tr><tr><td>Show Player if Not Present</td><td>If enabled and if player is not part of the list a new entry will be generated</td></tr><tr><td>Player Content</td><td>The container for the player entry</td></tr><tr><td>Empty Player Name</td><td>If player has no name this will be displayed instead</td></tr><tr><td>Empty Player Rank</td><td>If player has no rank in the leaderboard this will be displayed instead</td></tr><tr><td>Prefab Cell</td><td>The leaderboard entry UI</td></tr><tr><td>Content</td><td>The container for all leaderboard entries</td></tr><tr><td>Regular Background Color</td><td>A color used for the background of regular entries</td></tr><tr><td>Alternate Background Color</td><td>A color used to alternate regular entries color</td></tr><tr><td>Regular Text Color</td><td>Text color for regular entries</td></tr><tr><td>Player Text Color</td><td>Text color for the player entry</td></tr></tbody></table>


# Visual Scripting

## Triggers

#### On Leaderboard Updated

This is triggered when the specific leaderboard has been updated

<figure><img src="/files/aZZpFc2xUyDya7wB8krx" alt=""><figcaption></figcaption></figure>

## Instructions

#### Add Score

This will add up to the current score of the player

<figure><img src="/files/GyinmKFrgulyZcANyMQp" alt=""><figcaption></figcaption></figure>

#### Get Member Rank

Use this to get the rank and score for an specific player

<figure><img src="/files/7fzNbgCe6su3d7syvv9c" alt=""><figcaption></figcaption></figure>

#### Submit Score

Use this to submit a score to a leaderboard

<figure><img src="/files/BPo8MZpRCPoASF2qCxnR" alt=""><figcaption></figcaption></figure>


# Messages


# Progressions


# Replenish System

Create time-based system. Use the server's time to make sure players can't cheat by changing the time on their device

## Initialization

To use this system simply call the **Initialize Replenish Value** instruction.

<figure><img src="/files/ZSQ0zTrVlyUW9jEmINHd" alt=""><figcaption></figcaption></figure>

#### Replenish Key

A key needed to store the value in Player's storage

#### Initial Value

The initial value that will have the Player's storage value

#### Max Value

The maximum value the player can earn with the system

#### Interval

How often this value will be incremented by 1.

#### Auto Collect Offline Earnings

If enabled offline earnings will be auto collected, otherwise an event will be triggered that can be used to do it manually

## Offline Earnings

Offline earnings can be received manually by using a trigger.

<figure><img src="/files/hA0ODLaHkenDh49pLFgf" alt=""><figcaption></figcaption></figure>

Once this trigger is execute the instruction **Collect Offline Earnings** can be used

<figure><img src="/files/vdibzRAeRmQu5Zbn8xsz" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
To see this in action you can play the demo scene **9\_ReplenishSystem**
{% endhint %}


# Date Time


# Server Time


# Handling Errors


# Releases

## 1.1.5 (30th October 2024)

* Unity 6 support
* Moved LootLocker module to a package folder structure
* Game Creator 2.17.51 support
* LootLocker 3.2.2 SDK support
* Added version manager in settings
* Updated all examples and extensions packages

## 1.0.4 (10th August 2024)

* Fixed issues with Save & Load using LootLocker storage
* Game Creator 2.16.50 compatibility

## 1.0.3 (13th March 2024)

* Game Creator 2.15.49 compatibility

## 1.0.2 (24th November 2023)

* Game Creator 2.14.45 compatibilty
* LootLocker 2.1.1 compatibility
* Updated all demos

## 1.0.1 (3rd July 2023)

* Fixed issues with some demos
* Fixed an issue when white label email accounts verification is activated
* Prevent showing file not found error when loading SaveLoad data and player doesn't have it

## 1.0.0 (21st June 2023)

* First release.


# State Machine 2

{% hint style="danger" %}
**Having troubles?** Join our channel in Game Creator's [**Discord server**](https://discord.com/invite/99bbWBzKDX) for realtime discussions.
{% endhint %}

This module allows you to create state machines with [Game Creator 2](https://www.ninjutsugames.com/go/game-creator-2?src=docs_state_machine_overview_game_creator).\
Keep things clean and organize your triggers, actions and conditions in a simple State Machine, easily re-use them with any type of game object.

{% embed url="<https://youtu.be/NFub2Fv-GZc>" %}

## Key features <a href="#key-features" id="key-features"></a>

* Node-Based Graph with amazing performance.
* Multiple types of Nodes (Triggers, Actions, Branch, Conditions, Sub-StateMachine)
* Re-use State Machines for any type of logic Game Modes, AI, Player Managers etc.
* Variables from all types for State Machine asset and Runner.
* Disable or Lock nodes
* MiniMap to easily navigate through the graph
* Group nodes
* Add Sticky Notes
* Easily Align Nodes
* Tons of Shortcuts
* Complete undo support
* Copy & Paste nodes between State Machines.
* Drag & Drop regular GC Actions, Conditions and Triggers to a StateMachine to easily port your previous work.
* Duplicate State Machines.
* Add as many Sub-State Machines as you need.
* Drag & Drop state machines inside other SM's to create Sub-State Machines.
* Easily export State Machines to share between projects or to other users.
* Use any type of triggers, actions and conditions inside a State Machine.
* Works with any other official or un-official Game Creator modules.
* Live Debug runtime states right in the Editor.
* Compatible with all modules.

{% hint style="success" %}
All actions and conditions are compatible with other Game Creator modules.
{% endhint %}

## Setup <a href="#setup" id="setup"></a>

You'll first need to have Game Creator 2 installed.

The process is simple:

1. Install [**Game Creator 2**](https://www.ninjutsugames.com/go/game-creator-2?src=docs_state_machine_setup_game_creator)
2. Install [**State Machine 2**](https://www.ninjutsugames.com/go/state-machine?src=docs_state_machine_setup_module)

Finally bring up the ***Game Creator Install Window*** select the **State Machine 2** package and install it.

<figure><img src="/files/R7eHLYPhgwltSCxiN7CZ" alt=""><figcaption></figcaption></figure>

{% hint style="danger" %}
This module requires **Game Creator 2** and won't work without it. Don't attempt to extract the package inside the Plugins/ folder as it will throw some errors.
{% endhint %}


# Getting Started

Get up and running with State Machine 2 in minutes

This guide will help you create your first state machine in just a few minutes.

## Prerequisites

Before you begin, ensure you have:

* Unity 6000.3.1f1 or later
* [Game Creator 2](https://www.ninjutsugames.com/go/game-creator-2?src=docs_state_machine_getting_started_game_creator) installed
* [State Machine 2](https://www.ninjutsugames.com/go/state-machine?src=docs_state_machine_getting_started_module) installed

## Step 1: Create a State Machine Asset

1. In the **Project** window, navigate to where you want to create your state machine
2. Right-click and select **Create → Ninjutsu Games → State Machine**
3. Name your state machine (e.g., "EnemyAI" or "PlayerController")

## Step 2: Open the Graph Editor

Double-click your new State Machine asset to open the Graph Editor.

You'll see a canvas with a **Start Node** and **Exit Node** already created. These nodes are automatically added to every new state machine and cannot be deleted.

## Step 3: Add an Actions Node

Let's add some behavior:

1. Right-click on the canvas
2. Select **Create Node → Actions**
3. Click on the new Actions node to select it
4. In the Inspector, click **Add Action**
5. Choose an action (e.g., **Debug → Log Message**)
6. Configure the action (e.g., type "Hello from State Machine!")

## Step 4: Connect the Nodes

1. Click on the **output port** (right side) of the Start node
2. Drag the connection to the **input port** (left side) of the Actions node
3. Release to create the connection

## Step 5: Add a State Machine Runner

The Runner component executes your state machine on a GameObject:

1. Create or select a GameObject in your scene
2. Click **Add Component**
3. Search for **State Machine Runner**
4. Drag your State Machine asset to the **State Machine** field

{% hint style="info" %}
You can also create a runner via **Create → Ninjutsu Games → State Machine Runner**
{% endhint %}

## Step 6: Test It!

1. Press **Play** in Unity
2. Check the Console window — you should see your log message!

🎉 **Congratulations!** You've created your first state machine!

***

## Next Steps

Now that you have the basics, explore these topics:

### Add More Behavior

* [**Trigger Nodes**](/game-creator-2/state-machine-2/nodes) — React to events like player input, collisions, or timers
* [**Branch Nodes**](/game-creator-2/state-machine-2/nodes) — Create conditional logic paths
* [**Sub-State Machines**](/game-creator-2/state-machine-2/nodes) — Organize complex logic into reusable modules

### Use Variables

* [**Variables**](/game-creator-2/state-machine-2/variables) — Store and share data between nodes

### Learn the Editor

* [**Graph Editor**](/game-creator-2/state-machine-2/graph-editor) — Master the visual editor
* [**Shortcuts**](/game-creator-2/state-machine-2/shortcuts) — Speed up your workflow

### Build Real Systems

Try building these common use cases:

| System                 | Nodes to Use                                          |
| ---------------------- | ----------------------------------------------------- |
| **Enemy AI**           | Start → Trigger (On Player Near) → Actions (Chase)    |
| **Door Controller**    | Trigger (On Interact) → Branch (Is Locked?) → Actions |
| **Ability Cooldown**   | Actions → Trigger (On Timer) → Actions (Ready)        |
| **Game State Manager** | Start → Sub-State Machine (Menu, Playing, Paused)     |

***

## Example: Simple Enemy AI

Here's a complete example of a basic enemy AI:

### Nodes Setup

1. **Start Node** — Entry point
2. **Trigger Node** — "On Player Enter" (using a trigger collider)
3. **Actions Node** — "Chase Player" (move towards player)
4. **Trigger Node** — "On Player Exit"
5. **Actions Node** — "Return to Patrol"

### Connections

```
Start → Idle Actions
Idle Actions ← → Chase Trigger → Chase Actions
Chase Actions ← → Exit Trigger → Idle Actions
```

This creates a loop where the enemy:

1. Starts idle
2. Detects the player → starts chasing
3. Loses the player → returns to idle

***

## Troubleshooting

### State Machine Not Running

* Ensure the **State Machine Runner** component is on an **active GameObject**
* Check that the **State Machine** field has an asset assigned
* Verify the Start node has at least one output connection

### Actions Not Executing

* Check if nodes are **enabled** (not grayed out)
* Verify connections exist between nodes
* Use **Live Debug** in the Graph Editor to see execution flow

### Need Help?

* Join our [Discord Community](https://discord.com/invite/99bbWBzKDX)
* Check the [full documentation](https://docs.ninjutsugames.com/game-creator-2/state-machine-2/)
* Email support: <support@ninjutsugames.com>


# Graph Editor

The Graph Editor is the heart of State Machine 2, where you design and visualize your state machine logic.

## Opening the Editor

There are several ways to open the Graph Editor:

* **Window Menu**: Go to `Window → Ninjutsu Games → State Machine 2`
* **Double-click**: Double-click any State Machine asset in the Project window
* **Inspector Button**: Click the "Open" button in the State Machine Runner inspector
* **Context Menu**: Right-click a State Machine asset and select "Open"

{% hint style="info" %}
You can open **multiple Graph Editor windows** at the same time to work on different state machines simultaneously.
{% endhint %}

## Editor Overview

<figure><img src="/files/cgYfQFWMG3ipTfzOspZQ" alt=""><figcaption><p>The State Machine 2 Graph Editor</p></figcaption></figure>

The editor consists of several key areas:

### Toolbar

The toolbar at the top provides quick access to common operations:

| Button           | Description                            |
| ---------------- | -------------------------------------- |
| **Save**         | Save the current state machine         |
| **Minimap**      | Toggle the minimap visibility          |
| **Expand All**   | Expand all nodes to show their details |
| **Collapse All** | Collapse all nodes to compact view     |
| **Search**       | Open the node search dialog            |

### Graph Canvas

The main workspace where you create and connect nodes:

* **Pan**: Hold middle mouse button or Alt + left mouse button and drag
* **Zoom**: Use the mouse scroll wheel
* **Select**: Click on a node or drag a selection box
* **Multi-select**: Hold Shift or Ctrl while clicking nodes

### Node Inspector

<figure><img src="/files/7RWRL2bHD2ChRL1n5AnK" alt=""><figcaption><p>Node Inspector showing node properties</p></figcaption></figure>

When you select a node, the Inspector panel appears on the right side. Here you can:

* Edit the node's properties
* Configure actions, conditions, and triggers
* View and modify transitions
* Set networking options

{% hint style="success" %}
You can select **multiple nodes** and edit their common properties at the same time.
{% endhint %}

### Minimap

The minimap in the corner provides an overview of your entire graph. Click and drag on the minimap to quickly navigate large state machines.

## Creating Nodes

There are several ways to create new nodes:

### Right-Click Context Menu

Right-click anywhere on the canvas to open the node creation menu:

* **Start Node** — Entry point for the state machine
* **Actions Node** — Execute Game Creator 2 actions
* **Conditions Node** — Evaluate conditions before transitioning
* **Branch Node** — Create multiple conditional paths
* **Trigger Node** — React to Game Creator 2 triggers
* **Sub-State Machine** — Embed another state machine
* **Exit Node** — Terminate execution with callbacks

### Drag & Drop

Drag and drop from the Project window:

* **Game Creator Actions** → Automatically creates an Actions node
* **Game Creator Conditions** → Automatically creates a Conditions node
* **Game Creator Triggers** → Automatically creates a Trigger node
* **State Machine Assets** → Creates a Sub-State Machine node

## Connecting Nodes

To create transitions between nodes:

1. Click on an **output port** (right side of a node)
2. Drag the connection line to an **input port** (left side of another node)
3. Release to create the connection

{% hint style="warning" %}
**Start nodes** only have output ports. **Exit nodes** only have input ports.
{% endhint %}

### Transition Conditions

Connections between nodes can have conditions:

1. Select a connection line
2. In the Inspector, add conditions that must be met for the transition to occur

## Organizing Your Graph

### Groups

Group related nodes together for better organization:

1. Select multiple nodes
2. Right-click and select "Group Selection" or press `Ctrl/Cmd + G`
3. Name your group and choose a color

Groups can be collapsed to hide their contents.

### Sticky Notes

Add notes to document your state machine:

1. Right-click on the canvas
2. Select "Create Sticky Note"
3. Enter your documentation text

### Alignment

Keep your graph tidy with alignment tools:

* Select multiple nodes
* Right-click and use the alignment options (Align Left, Right, Top, Bottom, Center)

## Live Debugging

During Play mode, the Graph Editor provides real-time visualization:

* **Active nodes** are highlighted
* **Running transitions** show the current execution path
* **Variable values** update in real-time in the Blackboard

{% hint style="success" %}
**Tip**: Keep the Graph Editor open during Play mode to see your state machine in action!
{% endhint %}

## Settings

Access State Machine 2 settings via `Edit → Preferences → State Machine 2`:

| Setting                   | Description                                     |
| ------------------------- | ----------------------------------------------- |
| **Show Node Inspector**   | Toggle the inline node inspector                |
| **Auto-Rename Nodes**     | Automatically name nodes based on their content |
| **Minimap Default State** | Show or hide minimap by default                 |


# State Machine Runner

The State Machine Runner is the component in charge of executing your state machine asset or embedded.

<figure><img src="/files/gvavPQTaIcAszvOYLb60" alt=""><figcaption></figcaption></figure>

### The Buttons

<figure><img src="/files/pSiFT3jhZllywHG4ADnP" alt=""><figcaption></figcaption></figure>

**`Edit`** this button will open or reload the current existing graph view window with the selected State machine

**`New Window`** this will open a new graph window. You can open as many as you want with different State Machines.

**`Clear`** this will remove any existing embedded data for an embedded State Machine

**`Embed`** embed or create an scene State Machine allowing you to use scene references directly

**`Detach`** this will roll back to the State Machine asset if there was any. Existing embedde data won't be deleted.

{% hint style="info" %}
If no State Machine asset is present it will create and embed a new State Machine
{% endhint %}

{% hint style="success" %}
If a State Machine asset is present it will create a copy of it and embed it into the runner
{% endhint %}


# Nodes

All the node types available in State Machine 2

State Machine 2 provides a variety of node types to build any game logic you can imagine.

## Node Types Overview

| Node                     | Icon          | Purpose                            |
| ------------------------ | ------------- | ---------------------------------- |
| 🟢 **Start**             | Entry point   | Begins state machine execution     |
| ⚡ **Actions**            | Execute tasks | Runs Game Creator 2 actions        |
| 🔀 **Branch**            | Decision      | Multiple conditional paths         |
| ❓ **Conditions**         | Evaluate      | Check conditions before proceeding |
| 🎯 **Trigger**           | Events        | React to game events               |
| 📦 **Sub-State Machine** | Modular       | Embed another state machine        |
| 🚪 **Exit**              | Terminate     | End execution with callbacks       |
| ➡️ **Relay**             | Organization  | Visual routing (no logic)          |

***

## 🟢 Start Node

The **Start Node** is the entry point of your state machine. Execution begins here when the runner starts.

<img src="/files/M67o2YqwHqGE7vR3Pb8I" alt="Start Node" data-size="original">

### Features

* **Automatically created** when you create a new state machine
* Cannot be manually created or deleted
* Can include initial actions
* Only has **output ports** (no inputs)

### Connections

| Port   | Direction | Connects To                                          |
| ------ | --------- | ---------------------------------------------------- |
| Output | →         | Actions, Branch, Conditions, Sub-State Machine, Exit |

{% hint style="info" %}
The Start node executes immediately when the State Machine Runner starts. Connect it to your initial behavior.
{% endhint %}

***

## ⚡ Actions Node

The **Actions Node** executes one or more Game Creator 2 actions in sequence.

![](/files/K1SFBzqCDKDyH9plp4WE)

### Features

* Add unlimited actions
* Actions execute in order (top to bottom)
* Supports async actions (waits for completion)
* Can be triggered by any node type

### Connections

| Port   | Direction | Connects To                                                    |
| ------ | --------- | -------------------------------------------------------------- |
| Input  | ←         | Start, Actions, Branch, Conditions, Trigger, Sub-State Machine |
| Output | →         | Any node                                                       |

### Use Cases

* Play animations or sounds
* Modify variables
* Control characters
* Spawn objects
* Any Game Creator 2 action

***

## 🔀 Branch Node

The **Branch Node** creates multiple conditional paths, similar to a switch statement.

![](/files/g6iVt2qEgLPcox3EiFJH)

### Features

* Add multiple branches with conditions
* Each branch has its own conditions and actions
* First matching branch executes
* Default output if no conditions match

### Connections

| Port           | Direction | Connects To                       |
| -------------- | --------- | --------------------------------- |
| Input          | ←         | Any node                          |
| True Outputs   | →         | Per-branch outputs                |
| Default Output | →         | Fallback when no conditions match |

### Example

```
Branch Node:
├─ Branch 1: "Health < 25%" → Flee Actions
├─ Branch 2: "Has Weapon" → Attack Actions
└─ Default → Patrol Actions
```

***

## ❓ Conditions Node

The **Conditions Node** evaluates conditions and routes execution based on the result.

![](/files/OEyEmlTdkKUwRAbrLYQx)

### Features

* Add multiple conditions (AND logic)
* Two outputs: True and False
* Can be triggered by other nodes or triggers

### Connections

| Port          | Direction | Connects To              |
| ------------- | --------- | ------------------------ |
| Input         | ←         | Any node                 |
| Trigger Input | ↑         | Trigger nodes only       |
| True Output   | →         | When all conditions pass |
| False Output  | →         | When any condition fails |

### Use Cases

* Check player state before actions
* Validate game conditions
* Gate progression

***

## 🎯 Trigger Node

The **Trigger Node** reacts to Game Creator 2 events and triggers, providing event-driven execution.

![](/files/PMhlxZw7oPCFRyq9Wid3)

### Features

* Use any GC2 trigger type
* Event-driven (waits for trigger)
* Self-contained entry point
* Works with collision, input, timers, and more

### Connections

| Port             | Direction | Connects To                                    |
| ---------------- | --------- | ---------------------------------------------- |
| Output           | →         | Actions, Branch, Conditions, Sub-State Machine |
| Condition Output | ↓         | Directly to Conditions nodes                   |

### Common Triggers

| Trigger                | Description           |
| ---------------------- | --------------------- |
| **On Start**           | When runner begins    |
| **On Update**          | Every frame           |
| **On Trigger Enter**   | Collision detection   |
| **On Input**           | Player input          |
| **On Timer**           | Timed events          |
| **On Variable Change** | React to data changes |

{% hint style="success" %}
Trigger nodes can act as **alternative entry points**, running in parallel with the Start node.
{% endhint %}

***

## 📦 Sub-State Machine Node

The **Sub-State Machine Node** embeds another state machine, enabling modular and reusable design.

### Features

* Reference any State Machine asset
* Nested execution
* Exit nodes in the sub-machine connect to this node's outputs
* Perfect for reusable behavior modules

### Connections

| Port   | Direction | Connects To                                |
| ------ | --------- | ------------------------------------------ |
| Input  | ←         | Any node                                   |
| Output | →         | Triggered by Exit nodes in the sub-machine |

### Use Cases

* **Reusable AI behaviors** (Patrol, Combat, Flee)
* **Game mode management** (Menu, Playing, Paused)
* **Complex sequences** (Cutscenes, Tutorials)

### Creating Sub-State Machines

1. Drag a State Machine asset into the graph
2. Or right-click → Create Node → Sub-State Machine
3. Assign the state machine asset in the Inspector

{% hint style="info" %}
**Tip:** Drag and drop a State Machine asset from the Project window directly onto the graph to instantly create a Sub-State Machine node.
{% endhint %}

***

## 🚪 Exit Node

The **Exit Node** terminates state machine execution and can trigger callbacks.

### Features

* **Automatically created** when you create a new state machine
* Cannot be manually created or deleted
* Clean termination point
* Triggers parent Sub-State Machine outputs
* Useful for signaling completion

### Connections

| Port           | Direction | Connects To          |
| -------------- | --------- | -------------------- |
| Input          | ←         | Any node             |
| *(No outputs)* | —         | Terminates execution |

### Use Cases

* End a sub-state machine and continue parent flow
* Signal completion of a behavior
* Clean shutdown with callbacks

***

## ➡️ Relay Node

The **Relay Node** is for visual organization only — it doesn't execute any logic.

### Features

* Route connections for cleaner graphs
* No execution overhead
* Purely visual organization

### Connections

| Port   | Direction | Connects To |
| ------ | --------- | ----------- |
| Input  | ←         | Any node    |
| Output | →         | Any node    |

### Use Cases

* Organize complex connection paths
* Improve graph readability
* Route around node clusters

***

## See Also

* [Node Features](/game-creator-2/state-machine-2/nodes/node-features) — Common features like rename, lock, disable
* [Graph Editor](/game-creator-2/state-machine-2/graph-editor) — Creating and connecting nodes
* [Getting Started](/game-creator-2/state-machine-2/getting-started) — Build your first state machine


# Node Features

All nodes in State Machine 2 share common features that help you organize and control your state machine logic.

## Rename

Every node can be renamed for better clarity:

1. **Double-click** on the node's title
2. Type the new name
3. Press Enter to confirm

![Double click to rename](/files/Zjw50daWtrAQYJtsi10R)

{% hint style="info" %}
Enable **Auto-Rename** in settings to automatically name nodes based on their trigger, first action, or condition.
{% endhint %}

## Lock

Locked nodes cannot be moved, preventing accidental repositioning:

* **Lock**: Right-click the node → Lock
* **Unlock**: Right-click the node → Unlock

A lock icon appears on locked nodes.

## Disable

Disabled nodes are skipped during execution:

* **Disable**: Right-click the node → Disable
* **Enable**: Right-click the node → Enable

Disabled nodes appear grayed out in the graph.

{% hint style="warning" %}
When a node is disabled, its **output transitions are also skipped**. The state machine will not progress through disabled nodes.
{% endhint %}

## Color Coding

Assign colors to nodes for visual organization:

1. Right-click on a node
2. Select **Set Color**
3. Choose from the color palette

This is useful for categorizing nodes by purpose (e.g., combat logic, UI, dialogue).

## Expanded View

Nodes can show their content inline without opening the inspector:

* **Expand**: Click the expand icon on the node, or right-click → Expand
* **Collapse**: Click the collapse icon, or right-click → Collapse

When expanded, you can edit actions, conditions, and triggers directly in the graph.

## Copy & Paste

Nodes can be copied between state machines:

* **Copy**: Select nodes and press `Ctrl/Cmd + C`
* **Paste**: Press `Ctrl/Cmd + V` in any state machine graph

{% hint style="success" %}
You can copy nodes between **different projects** and even **different Unity versions**!
{% endhint %}

## Duplicate

Quickly create a copy of selected nodes:

* Select nodes
* Press `Ctrl/Cmd + D` or right-click → Duplicate

The duplicates appear offset from the originals with all settings preserved.

## Delete

Remove nodes from the graph:

* Select nodes
* Press `Delete` or `Backspace`
* Or right-click → Delete

{% hint style="warning" %}
Deleting a node also removes all its connections. This action can be undone with `Ctrl/Cmd + Z`.
{% endhint %}

## Network Settings

Each node can have individual networking configuration for multiplayer games:

1. Select a node
2. In the Inspector, expand **Network Settings**
3. Configure sync options

See [Multiplayer](https://github.com/hjupter/documentation/tree/main/game-creator-2/state-machine-2/multiplayer.md) for detailed networking documentation.

## Context Menu Actions

Right-click on a node to access all available actions:

| Action              | Description                        |
| ------------------- | ---------------------------------- |
| **Rename**          | Change the node's display name     |
| **Duplicate**       | Create a copy of the node          |
| **Delete**          | Remove the node from the graph     |
| **Lock/Unlock**     | Toggle movement lock               |
| **Enable/Disable**  | Toggle node execution              |
| **Set Color**       | Assign a color to the node         |
| **Expand/Collapse** | Toggle inline editing view         |
| **Group Selection** | Create a group from selected nodes |


# Variables

State Machine and Runner Variables

State Machine 2 introduces two types of variables that integrate with Game Creator 2's visual scripting system.

{% hint style="success" %}
All variables can be created from the State Machine Asset, State Machine Runner, or the Blackboard in the Graph Editor.
{% endhint %}

## Variable Types

| Type                        | Scope                       | Use Case                        |
| --------------------------- | --------------------------- | ------------------------------- |
| **State Machine Variables** | Asset-level (global)        | Shared state across all runners |
| **Runner Variables**        | Instance-level (per runner) | Unique state per GameObject     |

## State Machine Variables

These variables are stored in the State Machine Asset itself. All runners using the same asset share these values.

<figure><img src="/files/C4l0528RoY893NL8m55H" alt=""><figcaption><p>State Machine Variables in the Blackboard</p></figcaption></figure>

### Use Cases

* Global game settings
* Shared configuration values
* Default values for all instances

### Behavior

* Changes affect all runners using the asset
* Values persist between play sessions (stored in asset)
* Reset when asset is reimported

{% hint style="warning" %}
Be careful when modifying State Machine Variables during runtime - changes will affect all active runners.
{% endhint %}

## State Machine Runner Variables

These variables are instance-specific. Each runner maintains its own copy with independent values.

<figure><img src="/files/CmPA1wSWQpje39Sv97Lp" alt=""><figcaption><p>Runner Variables in the Inspector</p></figcaption></figure>

### Use Cases

* Character-specific state (health, mana, ammo)
* Individual object behavior
* Per-instance configuration

### Behavior

* Each runner has independent values
* Values are initialized from the State Machine Asset
* Changes don't affect other runners

## Creating Variables

### From the Blackboard

1. Open the Graph Editor
2. Click **+** in the Blackboard panel
3. Choose the variable type
4. Name your variable

### From the Inspector

1. Select the State Machine Asset or Runner
2. Expand the Variables section
3. Click **Add Variable**
4. Configure the variable type and name

## Supported Types

| Type                 | Description                    |
| -------------------- | ------------------------------ |
| **Bool**             | True/false values              |
| **Integer**          | Whole numbers                  |
| **Float**            | Decimal numbers                |
| **String**           | Text values                    |
| **Color**            | RGBA color values              |
| **Vector2**          | 2D coordinates                 |
| **Vector3**          | 3D coordinates/positions       |
| **GameObject**       | Reference to a GameObject      |
| **Sprite**           | Reference to a Sprite          |
| **Texture**          | Reference to a Texture         |
| **Material**         | Reference to a Material        |
| **Animation Clip**   | Reference to an Animation Clip |
| **Audio Clip**       | Reference to an Audio Clip     |
| **Game Object List** | List of GameObjects            |

## Using Variables in Nodes

Variables can be accessed directly in node properties:

1. Click on a property field
2. Select **Variables → State Machine** or **Variables → Runner**
3. Choose the variable

## Accessing Variables via Visual Scripting

Use the [Properties](/game-creator-2/state-machine-2/visual-scripting/properties) system to read and write variables from any Game Creator 2 instruction or condition.

## Network Synchronization

When using multiplayer modules (Fusion or Photon):

1. Select a variable in the Blackboard
2. Enable **Network Sync**
3. The variable value syncs across all clients

{% hint style="info" %}
Only Runner Variables can be synced per-instance. State Machine Variables sync globally.
{% endhint %}

## Best Practices

### Use Runner Variables for Gameplay

Most gameplay values should be Runner Variables:

* Health, mana, stamina
* Inventory counts
* Quest progress
* Character state

### Use Asset Variables for Defaults

Asset Variables work well for:

* Default configuration
* Shared constants
* Initial values (copied to runners)

### Name Consistently

Use clear, descriptive names:

* `PlayerHealth` (good)
* `h` (bad)
* `EnemyChaseSpeed` (good)
* `speed` (ambiguous)


# Embedded Mode

Use scene references directly in your state machines

Embedded Mode allows you to create state machines that are stored directly on a Runner component, enabling direct references to scene objects.

## What is Embedded Mode?

By default, State Machine assets are stored in the Project folder and shared across all runners that reference them. This is great for reusable logic, but it means you cannot reference scene-specific GameObjects.

**Embedded Mode** solves this by storing the state machine graph directly on the Runner component, allowing:

* Direct references to scene GameObjects
* Unique behavior per Runner instance
* Scene-specific configurations

## When to Use Embedded Mode

| Use Case                    | Recommended Mode |
| --------------------------- | ---------------- |
| Reusable AI behavior        | Asset Mode       |
| Scene-specific interactions | Embedded Mode    |
| Shared game logic           | Asset Mode       |
| One-off sequences           | Embedded Mode    |
| Prefab behavior             | Asset Mode       |
| Level-specific events       | Embedded Mode    |

{% hint style="warning" %}
**Prefabs do not support Embedded Mode.** If you need prefab support, use Asset Mode with Runner Variables for instance-specific data.
{% endhint %}

## Creating an Embedded State Machine

1. Add a **State Machine Runner** component to a GameObject
2. In the Inspector, click **Create Embedded**
3. The Graph Editor opens with a new embedded graph
4. Design your state machine as usual

## Using Scene References

With Embedded Mode, you can drag scene objects directly into node properties:

1. Select a node that needs a GameObject reference
2. Drag a GameObject from the **Hierarchy** to the property field
3. The scene reference is stored in the embedded graph

### Example: Door Controller

```
Trigger Node: On Interact
├─ Target: [Scene Reference: InteractionZone]
└─ Output → Actions Node
              └─ Action: Rotate GameObject
                 └─ Target: [Scene Reference: DoorPivot]
```

## Opening an Embedded Graph

* Click **Open Graph** on the State Machine Runner component
* Or double-click the Runner component

The Graph Editor title shows **"(Embedded)"** to indicate you're editing an embedded graph.

## Converting Between Modes

### Asset → Embedded

1. With a Runner that has an Asset assigned
2. Click **Convert to Embedded** (if available)
3. The asset is copied to an embedded graph

{% hint style="danger" %}
Converting to embedded creates a **copy**. Changes to the original asset won't affect the embedded version.
{% endhint %}

### Embedded → Asset

1. Open the embedded graph
2. Use **File → Export as Asset**
3. Choose a location in your Project
4. Assign the new asset to the Runner


# Limitations

Understanding the constraints of Embedded Mode

Embedded Mode has specific constraints you should be aware of when designing your state machines.

## No Prefab Support

Embedded graphs cannot be used in prefabs because scene references are lost when a prefab is instantiated.

### Workarounds

* Use **Asset Mode** with prefabs
* Store instance-specific data in **Runner Variables**
* Use **Self** and **Target** references instead of direct scene references

{% hint style="warning" %}
If you try to create an embedded state machine on a prefab, you'll see a "Prefabs are not supported" message.
{% endhint %}

## No Sharing

Embedded graphs are unique to their Runner component. Each embedded graph is an independent copy that cannot be shared between GameObjects.

### Workarounds

* Export the embedded graph as an asset for reuse
* Use Sub-State Machines to share common patterns
* Keep shared logic in Asset Mode, use Embedded only for scene-specific parts

## Duplication Behavior

When duplicating a GameObject with an embedded Runner:

| Aspect            | Behavior                          |
| ----------------- | --------------------------------- |
| Graph             | Copied to the new GameObject      |
| Scene References  | Maintained if objects still exist |
| Broken References | Displayed as "Missing"            |

{% hint style="info" %}
After duplicating, check that all scene references are still valid. Broken references will show as "Missing" in the Inspector.
{% endhint %}

## Scene Dependencies

Embedded graphs create tight coupling with scene objects:

* Moving the graph to another scene requires updating references
* Deleting referenced objects breaks the graph
* Renaming referenced objects may require reassignment

## Memory Considerations

Each embedded graph is stored separately, which means:

* Multiple copies increase memory usage
* Large embedded graphs on many objects can impact performance
* Consider Asset Mode for complex, frequently-used state machines


# Best Practices

Tips for effectively using Embedded Mode

Follow these guidelines to get the most out of Embedded Mode.

## Use for Scene-Specific Logic

Embedded mode shines when you need to reference specific scene objects:

* Level triggers and events
* Scene-specific cutscenes
* Environmental interactions
* Tutorial sequences
* One-time scene setups

{% hint style="success" %}
**Rule of thumb**: If the logic only makes sense in one specific scene, Embedded Mode is a good choice.
{% endhint %}

## Keep It Simple

Embedded graphs should be focused and simple. For complex logic:

* Use Sub-State Machines referencing Asset state machines
* Keep scene-specific parts embedded, share common logic as assets
* Break large graphs into smaller, manageable pieces

### Hybrid Approach

```
Embedded Runner
├─ Trigger: Scene-specific event
└─ Sub-State Machine: [Asset] Shared AI Behavior
```

This pattern lets you use scene references for triggers while reusing complex logic.

## Document with Sticky Notes

Since embedded graphs can't be easily shared or viewed outside the scene, add Sticky Notes explaining:

* The purpose of the state machine
* Scene dependencies and references
* Any special conditions or requirements

## Use Self and Target References

When possible, prefer **Self** and **Target** references over direct scene references:

| Reference Type      | Use When                                               |
| ------------------- | ------------------------------------------------------ |
| **Self**            | Referencing the Runner's own GameObject                |
| **Target**          | Referencing a passed-in target                         |
| **Scene Reference** | Only when you need a specific, unchanging scene object |

## Consider Future Changes

Before using Embedded Mode, consider:

* Will this logic need to be reused?
* Might this become a prefab later?
* Will multiple objects need similar behavior?

If yes to any of these, start with Asset Mode instead.

## Backup Important Graphs

Embedded graphs are stored in the scene file. To protect your work:

1. Regularly export complex embedded graphs as assets
2. Use version control for your scenes
3. Consider using Asset Mode for critical game logic


# Troubleshooting

Common issues and solutions for Embedded Mode

Solutions to common problems when using Embedded Mode.

## "Prefabs are not supported"

**Problem**: You're trying to use Embedded Mode on a prefab.

**Solution**: Convert to Asset Mode instead:

1. Create a new State Machine asset in your Project
2. Design your logic in the asset
3. Assign the asset to the Runner on your prefab
4. Use Runner Variables for instance-specific data

## Missing References After Scene Reload

**Problem**: Scene references show as "Missing" after reloading the scene.

**Causes**:

* The referenced GameObject was deleted
* The scene was reloaded without saving
* The GameObject was renamed or moved

**Solutions**:

* Reassign the reference to the correct GameObject
* Use **Self** or **Target** patterns instead of direct references
* Ensure the scene is saved before closing

## Can't Open Embedded Graph

**Problem**: Unable to open the embedded graph for editing.

**Solutions**:

* Ensure the Runner component has an embedded graph (look for "Open Graph" button)
* If button shows "Create Embedded", click it to create a new embedded graph
* Check if the Runner is on a prefab (not supported)

## Graph Not Running

**Problem**: The embedded state machine doesn't execute.

**Checklist**:

1. Is the Runner component enabled?
2. Is the Start node connected to other nodes?
3. Are there any console errors?
4. Is the GameObject active in the scene?

## Changes Not Saving

**Problem**: Changes to the embedded graph are lost.

**Solutions**:

* Always save the scene after editing an embedded graph
* Check that the scene isn't read-only
* Ensure Unity has write permissions to the project folder

## Performance Issues

**Problem**: Many embedded state machines causing slowdown.

**Solutions**:

* Convert frequently-used logic to Asset Mode
* Simplify complex embedded graphs
* Use Sub-State Machines to share common patterns
* Profile using Unity's Profiler to identify bottlenecks

## Reference Became Invalid

**Problem**: A previously working reference stopped working.

**Common Causes**:

* GameObject was moved to a different scene
* GameObject was converted to/from a prefab
* Scene was duplicated without updating references

**Solution**: Re-drag the correct GameObject into the property field.


# Visual Scripting

Integrate with Game Creator 2's visual scripting system

State Machine 2 provides a comprehensive set of Visual Scripting components that integrate seamlessly with Game Creator 2's action system.

## Overview

All components are organized into four categories:

| Category         | Description                                                          |
| ---------------- | -------------------------------------------------------------------- |
| **Instructions** | Actions to control state machines (run, enable, disable, stop nodes) |
| **Conditions**   | Check node states (is running, is enabled)                           |
| **Events**       | React to variable changes                                            |
| **Properties**   | Read and write state machine variables                               |

## Asset vs Runner

State Machine 2 offers two modes for each component:

| Mode       | Scope                                             | Use Case                                |
| ---------- | ------------------------------------------------- | --------------------------------------- |
| **Asset**  | Affects all runners using the state machine asset | Global game state, shared behavior      |
| **Runner** | Affects only a specific runner instance           | Per-character state, individual objects |

{% hint style="info" %}
**Best Practice**: Use **Runner** components for most gameplay scenarios. Use **Asset** components only for truly global state that should be shared across all instances.
{% endhint %}

## Quick Reference

### Instructions

Control state machine execution:

* [**Run Node**](/game-creator-2/state-machine-2/visual-scripting/instructions/run-node) — Execute a specific node
* [**Run Node with Variables**](/game-creator-2/state-machine-2/visual-scripting/instructions/run-node-with-variables) — Execute with variable values
* [**Enable Node**](/game-creator-2/state-machine-2/visual-scripting/instructions/enable-node) — Re-enable a disabled node
* [**Disable Node**](/game-creator-2/state-machine-2/visual-scripting/instructions/disable-node) — Prevent a node from executing
* [**Stop Node**](/game-creator-2/state-machine-2/visual-scripting/instructions/stop-node) — Immediately stop a running node
* [**Loop List with Node**](/game-creator-2/state-machine-2/visual-scripting/instructions/loop-list-with-node) — Iterate and execute per element

### Conditions

Check state machine states:

* [**Node Is Running**](/game-creator-2/state-machine-2/visual-scripting/conditions/node-running) — Check if a node is executing
* [**Node Is Enabled**](/game-creator-2/state-machine-2/visual-scripting/conditions/node-enabled) — Check if a node is enabled

### Events

React to state changes:

* [**On Variable Change**](/game-creator-2/state-machine-2/visual-scripting/events/on-variable-change) — Triggered when an asset variable changes
* [**On Runner Variable Change**](/game-creator-2/state-machine-2/visual-scripting/events/on-runner-variable-change) — Triggered when a runner variable changes

### Properties

Read and write variables from anywhere in Game Creator 2:

* [**Get Properties**](/game-creator-2/state-machine-2/visual-scripting/properties#get-properties) — Read variable values
* [**Set Properties**](/game-creator-2/state-machine-2/visual-scripting/properties#set-properties) — Write variable values

## Finding Components in the Editor

All State Machine 2 visual scripting components are organized in the search menu:

```
State Machine/
├─ Asset/
│   ├─ Run State Machine Node
│   ├─ Enable State Machine Node
│   ├─ Disable State Machine Node
│   ├─ Stop State Machine Node
│   ├─ Node Running (Condition)
│   └─ Node Enabled (Condition)
├─ Runner/
│   ├─ Run State Machine Runner Node
│   ├─ Run Runner Node with Variables
│   ├─ Enable State Machine Runner Node
│   ├─ Disable State Machine Runner Node
│   ├─ Stop State Machine Runner Node
│   ├─ Node Running (Condition)
│   └─ Node Enabled (Condition)
└─ Loop List with Node

Variables/
├─ On State Machine Variable Change (Event)
├─ On State Machine Runner Variable Change (Event)
├─ State Machine Variable (Properties)
└─ State Machine Runner Variable (Properties)
```


# Instructions

Actions to control state machine execution

Instructions are actions you can use in Game Creator 2 Actions, Hotspots, or any other visual scripting context to control state machines.

## Runner Instructions

These instructions work with **State Machine Runner** components on specific GameObjects, affecting only that instance.

| Instruction                                                                                                                 | Description                                                  |
| --------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------ |
| [**Run State Machine Runner Node**](/game-creator-2/state-machine-2/visual-scripting/instructions/run-node)                 | Executes a specific node on a target runner                  |
| [**Run Runner Node with Variables**](/game-creator-2/state-machine-2/visual-scripting/instructions/run-node-with-variables) | Executes a node and passes variable values before execution  |
| [**Enable State Machine Runner Node**](/game-creator-2/state-machine-2/visual-scripting/instructions/enable-node)           | Re-enables a previously disabled node                        |
| [**Disable State Machine Runner Node**](/game-creator-2/state-machine-2/visual-scripting/instructions/disable-node)         | Disables a node, preventing it from executing                |
| [**Stop State Machine Runner Node**](/game-creator-2/state-machine-2/visual-scripting/instructions/stop-node)               | Immediately stops a currently running node                   |
| [**Loop List with Node**](/game-creator-2/state-machine-2/visual-scripting/instructions/loop-list-with-node)                | Iterates through a list and executes a node for each element |

{% hint style="info" %}
**Runner Instructions** affect only the specific runner instance on the target GameObject. Use these for per-instance control.
{% endhint %}

## Asset Instructions

These instructions work directly with **State Machine Asset** files, affecting all runners using that asset.

| Instruction                                                                                                    | Description                                       |
| -------------------------------------------------------------------------------------------------------------- | ------------------------------------------------- |
| [**Run State Machine Node**](/game-creator-2/state-machine-2/visual-scripting/instructions/run-node-1)         | Executes a node directly on a State Machine asset |
| [**Enable State Machine Node**](/game-creator-2/state-machine-2/visual-scripting/instructions/enable-node-1)   | Enables a node in the State Machine asset         |
| [**Disable State Machine Node**](/game-creator-2/state-machine-2/visual-scripting/instructions/disable-node-1) | Disables a node in the State Machine asset        |
| [**Stop State Machine Node**](/game-creator-2/state-machine-2/visual-scripting/instructions/stop-node-1)       | Stops a running node in the State Machine asset   |

{% hint style="warning" %}
**Asset Instructions** affect **all runners** using that State Machine asset. Use with caution in multiplayer or when multiple instances exist.
{% endhint %}

## Usage Example

```
Actions Component:
├─ Instruction: Run State Machine Runner Node
│   ├─ Target: Player (GameObject)
│   └─ Node: "CombatNode"
└─ Instruction: Enable State Machine Runner Node
    ├─ Target: Enemy (GameObject)
    └─ Node: "AlertNode"
```


# Run State Machine Runner Node

Executes a State Machine node from a specific target runner

Executes a State Machine node from an specific target runner.

## Description

This instruction triggers execution of a specific node on a State Machine Runner component. The node begins execution immediately when this instruction runs.

## Parameters

| Name       | Description                                                  |
| ---------- | ------------------------------------------------------------ |
| **Target** | The target GameObject that contains the State Machine Runner |
| **Node**   | The node to execute from the specified State Machine         |

## Keywords

`Execute`, `Call`, `Instruction`, `Action`, `State Machine`, `Run`

## Example

```
Actions Component:
└─ Run State Machine Runner Node
    ├─ Target: Enemy
    └─ Node: "AttackNode"
```

This triggers the "AttackNode" on the Enemy's State Machine Runner.

{% hint style="info" %}
The **Self** argument of the runner changes to the target GameObject during execution.
{% endhint %}


# Run Node with Variables

Executes a node and passes variable values to the runner

Executes a State Machine node from a specific target runner with variables.

## Description

This instruction sets variable values on the State Machine Runner before executing a node. This is useful for passing data to the state machine, such as targets, damage values, or other parameters.

## Parameters

| Name          | Description                                                  |
| ------------- | ------------------------------------------------------------ |
| **Target**    | The target GameObject that contains the State Machine Runner |
| **Variables** | List of variable name-value pairs to set before execution    |

## Keywords

`Execute`, `Call`, `Instruction`, `Action`, `State Machine`, `Run`

## Example

```
Actions Component:
└─ Run Runner Node with Variables
    ├─ Target: Enemy
    ├─ Variables:
    │   ├─ DamageAmount: 25
    │   └─ Attacker: Player
    └─ Node: "TakeDamageNode"
```

This sets `DamageAmount` and `Attacker` variables on the Enemy runner, then executes "TakeDamageNode".

{% hint style="success" %}
Use this instruction when you need to pass context-specific data to a state machine, such as who triggered an event or what values to use.
{% endhint %}

{% hint style="info" %}
If the target has a **State Machine Runner Instances** component, it will automatically find the correct runner for the specified State Machine.
{% endhint %}


# Enable State Machine Runner Node

Enables a State Machine node on a specific runner

Enables a State Machine node from a specific target runner.

## Description

Re-enables a previously disabled node on a State Machine Runner. Once enabled, the node can be executed normally through transitions or other instructions.

## Parameters

| Name       | Description                                                  |
| ---------- | ------------------------------------------------------------ |
| **Target** | The target GameObject that contains the State Machine Runner |
| **Node**   | The node to enable on the specified State Machine            |

## Keywords

`Enable`, `Instruction`, `Action`, `State Machine`, `Runner`

## Example

```
Actions Component:
└─ Enable State Machine Runner Node
    ├─ Target: Player
    └─ Node: "SpecialAbilityNode"
```

This re-enables the "SpecialAbilityNode" on the Player's State Machine Runner.

{% hint style="info" %}
Nodes are enabled by default. Use this instruction to restore a node that was previously disabled with the **Disable State Machine Runner Node** instruction.
{% endhint %}


# Disable State Machine Runner Node

Disables a State Machine node on a specific runner

Disables a State Machine node from a specific target runner.

## Description

Disables a node on a State Machine Runner, preventing it from executing. The node remains in the graph but will not run until it is enabled again.

## Parameters

| Name       | Description                                                  |
| ---------- | ------------------------------------------------------------ |
| **Target** | The target GameObject that contains the State Machine Runner |
| **Node**   | The node to disable on the specified State Machine           |

## Keywords

`Disable`, `Cancel`, `Instruction`, `Action`, `State Machine`, `Runner`

## Example

```
Actions Component:
└─ Disable State Machine Runner Node
    ├─ Target: Player
    └─ Node: "SprintNode"
```

This disables the "SprintNode" on the Player's State Machine Runner, preventing sprinting.

{% hint style="warning" %}
Disabled nodes will not execute even if transitions lead to them. Make sure to re-enable nodes when appropriate using **Enable State Machine Runner Node**.
{% endhint %}


# Stop State Machine Runner Node

Stops a running State Machine node on a specific runner

Stops a State Machine node from a specific target runner.

## Description

Immediately stops a currently executing node on a State Machine Runner. The node's execution is cancelled and any ongoing actions are interrupted.

## Parameters

| Name       | Description                                                  |
| ---------- | ------------------------------------------------------------ |
| **Target** | The target GameObject that contains the State Machine Runner |
| **Node**   | The node to stop on the specified State Machine              |

## Keywords

`Stop`, `Cancel`, `Instruction`, `Action`, `State Machine`, `Runner`

## Example

```
Actions Component:
└─ Stop State Machine Runner Node
    ├─ Target: Enemy
    └─ Node: "PatrolNode"
```

This immediately stops the "PatrolNode" on the Enemy's State Machine Runner.

{% hint style="danger" %}
Stopping a node interrupts it mid-execution. Any actions that were running will be cancelled. Use with care to avoid leaving the game in an inconsistent state.
{% endhint %}


# Loop List with Node

Iterates through a list and executes a node for each element

Loops a Game Object List Variable and executes a State Machine Node for each value.

## Description

Iterates through a list of GameObjects and executes a specific node for each element. The **Target** argument of any instruction inside the node contains the current object being processed.

## Parameters

| Name              | Description                                                  |
| ----------------- | ------------------------------------------------------------ |
| **List Variable** | Local List or Global List whose elements are iterated        |
| **Node**          | The node to execute for each element in the list             |
| **Target**        | The target GameObject that contains the State Machine Runner |

## Keywords

`Iterate`, `Cycle`, `Every`, `All`, `Stack`

## Example

```
Actions Component:
└─ Loop List with Node
    ├─ List Variable: EnemiesInRange
    ├─ Node: "ApplyDamageNode"
    └─ Target: Self
```

This iterates through all enemies in the `EnemiesInRange` list and executes the "ApplyDamageNode" for each one.

{% hint style="success" %}
This is perfect for applying effects to multiple targets, such as:

* Area of effect damage
* Buff/debuff all allies
* Process all items in an inventory
  {% endhint %}

{% hint style="info" %}
Inside the executed node, use the **Target** reference to access the current element being processed.
{% endhint %}


# Run State Machine Node

Executes a node directly on a State Machine asset

Executes a node from State Machine asset.

## Description

This instruction triggers execution of a specific node directly on a State Machine asset. Unlike runner instructions, this affects the asset itself and all runners using it.

## Parameters

| Name     | Description                                          |
| -------- | ---------------------------------------------------- |
| **Node** | The node to execute from the specified State Machine |

## Keywords

`Execute`, `Call`, `Instruction`, `Action`, `State Machine`, `Run`

## Example

```
Actions Component:
└─ Run State Machine Node
    └─ Node: "GlobalEventNode"
```

This executes the "GlobalEventNode" on the State Machine asset.

{% hint style="warning" %}
This instruction affects **all runners** using this State Machine asset. Use for global events that should trigger everywhere.
{% endhint %}


# Enable State Machine Node

Enables a node in a State Machine asset

Enables a node from State Machine asset.

## Description

Re-enables a previously disabled node in a State Machine asset. This affects all runners using this asset.

## Parameters

| Name     | Description                             |
| -------- | --------------------------------------- |
| **Node** | The node to enable in the State Machine |

## Keywords

`Enable`, `Instruction`, `Action`, `State Machine`, `Runner`

## Example

```
Actions Component:
└─ Enable State Machine Node
    └─ Node: "BonusLevelNode"
```

This enables the "BonusLevelNode" in the State Machine asset.

{% hint style="warning" %}
This instruction affects **all runners** using this State Machine asset.
{% endhint %}


# Disable State Machine Node

Disables a node in a State Machine asset

Disables a node from State Machine asset.

## Description

Disables a node in a State Machine asset, preventing it from executing on all runners using this asset.

## Parameters

| Name     | Description                              |
| -------- | ---------------------------------------- |
| **Node** | The node to disable in the State Machine |

## Keywords

`Disable`, `Cancel`, `Instruction`, `Action`, `State Machine`, `Runner`

## Example

```
Actions Component:
└─ Disable State Machine Node
    └─ Node: "DebugNode"
```

This disables the "DebugNode" in the State Machine asset.

{% hint style="warning" %}
This instruction affects **all runners** using this State Machine asset. The node will be disabled everywhere until re-enabled.
{% endhint %}


# Stop State Machine Node

Stops a running node in a State Machine asset

Stops a node from State Machine asset.

## Description

Immediately stops a currently executing node in a State Machine asset. This cancels execution on all runners using this asset.

## Parameters

| Name     | Description                           |
| -------- | ------------------------------------- |
| **Node** | The node to stop in the State Machine |

## Keywords

`Stop`, `Cancel`, `Instruction`, `Action`, `State Machine`, `Runner`

## Example

```
Actions Component:
└─ Stop State Machine Node
    └─ Node: "BackgroundProcessNode"
```

This stops the "BackgroundProcessNode" in the State Machine asset.

{% hint style="danger" %}
This instruction affects **all runners** using this State Machine asset. All running instances of this node will be stopped immediately.
{% endhint %}


# Conditions

Check state machine node states

Conditions check state machine states and can be used in Branch nodes, Conditions nodes, or any Game Creator 2 Condition context.

## Runner Conditions

Check states on specific State Machine Runner instances.

| Condition                                                                                       | Description                                              |
| ----------------------------------------------------------------------------------------------- | -------------------------------------------------------- |
| [**Node Is Running**](/game-creator-2/state-machine-2/visual-scripting/conditions/node-running) | Returns true if a node is executing on the target runner |
| [**Node Is Enabled**](/game-creator-2/state-machine-2/visual-scripting/conditions/node-enabled) | Returns true if a node is enabled on the target runner   |

## Asset Conditions

Check states on State Machine Assets directly, affecting all runners using that asset.

| Condition                                                                                         | Description                                    |
| ------------------------------------------------------------------------------------------------- | ---------------------------------------------- |
| [**Node Is Running**](/game-creator-2/state-machine-2/visual-scripting/conditions/node-running-1) | Returns true if a node is running on the asset |
| [**Node Is Enabled**](/game-creator-2/state-machine-2/visual-scripting/conditions/node-enabled-1) | Returns true if a node is enabled on the asset |

## Usage Example

```
Branch Node:
├─ Condition: "State Machine Runner Node Is Running"
│   ├─ Target: Self
│   └─ Node: "PatrolNode"
├─ True → Actions: Start Alert Behavior
└─ False → Actions: Continue Current State
```

{% hint style="info" %}
Use Runner conditions for per-instance checks (e.g., "is this specific enemy patrolling?"). Use Asset conditions for global checks (e.g., "is the game paused?").
{% endhint %}


# Runner Node Is Running

Check if a node is running on a specific runner

Returns true if the node is running on the specified State Machine Runner.

## Description

Checks whether a specific node is currently executing on a State Machine Runner instance. Useful for conditional logic based on current execution state.

## Parameters

| Name       | Description                                                  |
| ---------- | ------------------------------------------------------------ |
| **Target** | The target GameObject that contains the State Machine Runner |
| **Node**   | The node to check                                            |

## Returns

| Value     | Condition                                                      |
| --------- | -------------------------------------------------------------- |
| **True**  | The specified node is currently executing on the target runner |
| **False** | The node is not running or the runner doesn't exist            |

## Keywords

`State Machine`, `Is Running`, `Run`

## Example

```
Branch Node:
├─ Condition: State Machine Runner Node Is Running
│   ├─ Target: Self
│   └─ Node: "AttackNode"
├─ True → Skip (already attacking)
└─ False → Run Attack Actions
```

{% hint style="info" %}
Use this condition to prevent duplicate executions or to check if a character is in a specific state.
{% endhint %}


# Runner Node Is Enabled

Check if a node is enabled on a specific runner

Returns true if the node is enabled on the specified State Machine Runner.

## Description

Checks whether a specific node is enabled (not disabled) on a State Machine Runner instance. Enabled nodes can be executed; disabled nodes cannot.

## Parameters

| Name       | Description                                                  |
| ---------- | ------------------------------------------------------------ |
| **Target** | The target GameObject that contains the State Machine Runner |
| **Node**   | The node to check                                            |

## Returns

| Value     | Condition                                         |
| --------- | ------------------------------------------------- |
| **True**  | The specified node is enabled and can be executed |
| **False** | The node is disabled or the runner doesn't exist  |

## Keywords

`State Machine`, `Is Enabled`, `Run`

## Example

```
Branch Node:
├─ Condition: State Machine Runner Node Is Enabled
│   ├─ Target: Self
│   └─ Node: "SpecialAbilityNode"
├─ True → Show ability button
└─ False → Hide ability button (ability locked)
```

{% hint style="info" %}
Use this condition to check if features are unlocked or available before showing UI elements or allowing actions.
{% endhint %}


# Node Is Running

Check if a node is running on a State Machine asset

Returns true if the specified node is running.

## Description

Checks whether a specific node is currently executing on a State Machine asset. This checks the asset-level state, not any specific runner instance.

## Parameters

| Name     | Description       |
| -------- | ----------------- |
| **Node** | The node to check |

## Returns

| Value     | Condition                                            |
| --------- | ---------------------------------------------------- |
| **True**  | The specified node is currently running on the asset |
| **False** | The node is not running                              |

## Keywords

`State Machine`, `Is Running`, `Run`

## Example

```
Branch Node:
├─ Condition: State Machine Node Is Running
│   └─ Node: "GamePausedNode"
├─ True → Skip game logic
└─ False → Continue game logic
```

{% hint style="warning" %}
This condition checks asset-level state, which may differ from individual runner states in some scenarios.
{% endhint %}


# Node Is Enabled

Check if a node is enabled on a State Machine asset

Returns true if the specified node is enabled.

## Description

Checks whether a specific node is enabled (not disabled) on a State Machine asset. This checks the asset-level state.

## Parameters

| Name     | Description       |
| -------- | ----------------- |
| **Node** | The node to check |

## Returns

| Value     | Condition                                  |
| --------- | ------------------------------------------ |
| **True**  | The specified node is enabled on the asset |
| **False** | The node is disabled                       |

## Keywords

`State Machine`, `Is Running`, `Run`

## Example

```
Branch Node:
├─ Condition: State Machine Node Is Enabled
│   └─ Node: "CheatModeNode"
├─ True → Allow cheat commands
└─ False → Ignore cheat commands
```

{% hint style="warning" %}
This condition checks asset-level state, affecting all runners using this State Machine.
{% endhint %}


# Events

React to state machine variable changes

Events trigger when state machine states change. Use these in Trigger nodes or Game Creator 2 Triggers to react to changes.

## Available Events

| Event                                                                                                                            | Description                                            |
| -------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------ |
| [**On State Machine Variable Change**](/game-creator-2/state-machine-2/visual-scripting/events/on-variable-change)               | Fires when a State Machine Asset variable is modified  |
| [**On State Machine Runner Variable Change**](/game-creator-2/state-machine-2/visual-scripting/events/on-runner-variable-change) | Fires when a State Machine Runner variable is modified |

## Usage Example

```
Trigger Node:
├─ Event: On State Machine Runner Variable Change
│   ├─ Variable: "Health"
│   └─ Runner: Self
└─ Output → Actions: Update Health UI
```

{% hint style="success" %}
Variable change events are perfect for creating reactive UI that updates automatically when game state changes.
{% endhint %}


# On Variable Change

Triggered when a State Machine asset variable changes

Executed when the State Machine Variable is modified.

## Description

This event fires whenever a variable on a State Machine asset is changed. Use this to react to global state changes across all instances.

## Parameters

| Name         | Description                         |
| ------------ | ----------------------------------- |
| **Variable** | The variable to monitor for changes |

## Keywords

`Variable`, `Change`, `State Machine`

## Example

```
Trigger Component:
├─ Event: On State Machine Variable Change
│   └─ Variable: "GameMode"
└─ Actions:
    └─ Update UI to reflect new game mode
```

{% hint style="info" %}
Use this event for global variables that affect the entire game, such as game mode, difficulty settings, or global unlocks.
{% endhint %}

{% hint style="warning" %}
This monitors **asset-level** variables. For per-instance variables, use **On State Machine Runner Variable Change** instead.
{% endhint %}


# On Runner Variable Change

Triggered when a State Machine Runner variable changes

Executed when the State Machine Runner Variable is modified.

## Description

This event fires whenever a variable on a specific State Machine Runner is changed. Use this to react to per-instance state changes.

## Parameters

| Name         | Description                                               |
| ------------ | --------------------------------------------------------- |
| **Variable** | The variable to monitor for changes                       |
| **Runner**   | The target GameObject containing the State Machine Runner |

## Keywords

`Variable`, `Change`, `State Machine`, `Runner`

## Example

```
Trigger Component:
├─ Event: On State Machine Runner Variable Change
│   ├─ Variable: "Health"
│   └─ Runner: Self
└─ Actions:
    ├─ Update health bar UI
    └─ Play damage effect if health decreased
```

{% hint style="success" %}
This is the most common event for reactive gameplay systems. Use it to:

* Update UI when stats change
* Trigger effects when state changes
* Sync visuals with game logic
  {% endhint %}

{% hint style="info" %}
The **Runner** parameter is typically set to **Self** to monitor the runner on the same GameObject as the Trigger.
{% endhint %}


# Properties

Read and write State Machine variables from anywhere

Properties allow you to read and write State Machine variables from anywhere in Game Creator 2's visual scripting system.

## Get Properties

Read values from State Machine or Runner variables. Available in any Game Creator 2 property field.

| Type               | Asset | Runner | Description                             |
| ------------------ | :---: | :----: | --------------------------------------- |
| **Animation Clip** |   ✓   |    ✓   | Get an animation clip reference         |
| **Audio Clip**     |   ✓   |    ✓   | Get an audio clip reference             |
| **Bool**           |   ✓   |    ✓   | Get a boolean (true/false) value        |
| **Color**          |   ✓   |    ✓   | Get a color value (RGBA)                |
| **Decimal**        |   ✓   |    ✓   | Get a decimal number value              |
| **Direction**      |   ✓   |    ✓   | Get a direction vector                  |
| **GameObject**     |   ✓   |    ✓   | Get a GameObject reference              |
| **Material**       |   ✓   |    ✓   | Get a material reference                |
| **Position**       |   ✓   |    ✓   | Get a world position (Vector3)          |
| **Rotation**       |   ✓   |    ✓   | Get a rotation value (Quaternion/Euler) |
| **Scale**          |   ✓   |    ✓   | Get a scale vector                      |
| **Sprite**         |   ✓   |    ✓   | Get a sprite reference                  |
| **String**         |   ✓   |    ✓   | Get a text string value                 |
| **Texture**        |   ✓   |    ✓   | Get a texture reference                 |

## Set Properties

Write values to State Machine or Runner variables. Available in Game Creator 2 Set property actions.

| Type               | Asset | Runner | Description                                |
| ------------------ | :---: | :----: | ------------------------------------------ |
| **Animation Clip** |   ✓   |    ✓   | Set an animation clip reference            |
| **Bool**           |   ✓   |    ✓   | Set a boolean (true/false) value           |
| **Color**          |   ✓   |    ✓   | Set a color value (RGBA)                   |
| **Float**          |   ✓   |    ✓   | Set a floating-point number                |
| **GameObject**     |   ✓   |    ✓   | Set a GameObject reference                 |
| **Material**       |   ✓   |    ✓   | Set a material reference                   |
| **Sprite**         |   ✓   |    ✓   | Set a sprite reference                     |
| **String**         |   ✓   |    ✓   | Set a text string value                    |
| **Texture**        |   ✓   |    ✓   | Set a texture reference                    |
| **Vector3**        |   ✓   |    ✓   | Set a 3D vector (position/direction/scale) |

## How to Use Properties

1. In any Game Creator 2 action that accepts a property value, click the property dropdown
2. Navigate to **Variables → State Machine** or **Variables → State Machine Runner**
3. Select the variable you want to read or write
4. For Runner properties, also specify the target GameObject

## Usage Examples

### Reading a Variable

```
Action: Set Text
└─ Text: [Property] Variables → State Machine Runner Variable
    ├─ Variable: "PlayerName"
    └─ Runner: Self
```

### Writing a Variable

```
Action: Change Material Color
└─ Color: [Property] Variables → State Machine Variable
    └─ Variable: "HighlightColor"
```

## Asset vs Runner Properties

| Use Case                                         | Use Asset | Use Runner |
| ------------------------------------------------ | :-------: | :--------: |
| Shared state across all instances                |     ✓     |            |
| Per-instance behavior (each enemy has own state) |           |      ✓     |
| Global game state (game mode, settings)          |     ✓     |            |
| Individual character state (health, ammo)        |           |      ✓     |
| Prefab-based objects                             |           |      ✓     |
| Singleton managers                               |     ✓     |            |

{% hint style="info" %}
**Best Practice**: Use **Runner** properties for most gameplay scenarios. Use **Asset** properties only for truly global state that should be shared across all instances.
{% endhint %}

## Special Properties

### GameObject List

In addition to single GameObject properties, State Machine 2 supports **GameObject List** properties for working with collections of objects.

| Property                | Description                                              |
| ----------------------- | -------------------------------------------------------- |
| **Get GameObject List** | Read a list of GameObjects from a State Machine variable |
| **Set GameObject List** | Write a list of GameObjects to a State Machine variable  |

### State Machine Instance

Get a reference to the State Machine Runner's instance GameObject:

| Property         | Description                                                         |
| ---------------- | ------------------------------------------------------------------- |
| **Get Instance** | Returns the GameObject that the State Machine Runner is attached to |

{% hint style="success" %}
Use the Instance property when you need to reference the runner's GameObject from within the state machine logic.
{% endhint %}


# Multiplayer

Multiplayer integration with Photon Fusion and PUN2

State Machine 2 provides built-in support for multiplayer games using Photon Fusion or Photon PUN2.

## Requirements

To use multiplayer features, you need one of the following modules installed:

| Module                                             | Networking Solution |
| -------------------------------------------------- | ------------------- |
| [Fusion Module](/game-creator-2/fusion-module)     | Photon Fusion       |
| [Photon Module 2](/game-creator-2/photon-module-2) | Photon PUN2         |

{% hint style="info" %}
The multiplayer features in State Machine 2 appear automatically when either module is detected.
{% endhint %}

## Per-Node Network Settings

Each node in a state machine can have individual networking configuration:

1. Select a node in the Graph Editor
2. Expand **Network Settings** in the Inspector
3. Configure the sync options

### Network Options

| Option                 | Description                            |
| ---------------------- | -------------------------------------- |
| **Run on All**         | Execute on all clients                 |
| **Run on Owner**       | Execute only on the owning client      |
| **Run on Master/Host** | Execute only on the host/master client |
| **RPC**                | Send as a Remote Procedure Call        |

## State Synchronization

State Machine 2 automatically handles state synchronization for networked games:

### Node State Sync

* Active node states are synchronized across clients
* Transitions are replicated to maintain consistency
* Late-joining clients receive the current state

### Variable Sync

State Machine variables can be synchronized:

1. Open the **Blackboard**
2. Select a variable
3. Enable **Network Sync** (requires Fusion/Photon Module)


# Fusion Integration

Using State Machine 2 with Photon Fusion

When using the [Fusion Module](/game-creator-2/fusion-module), State Machine 2 integrates with Fusion's network architecture.

## Setup

1. Install [**Fusion Module**](https://www.ninjutsugames.com/go/fusion?src=docs_state_machine_fusion_integration) for Game Creator 2
2. Install **State Machine 2**
3. Network settings automatically appear in node inspectors

## Authority

| Authority Type      | Description                                               |
| ------------------- | --------------------------------------------------------- |
| **Input Authority** | Player-controlled state machines run on the owning client |
| **State Authority** | Server-authoritative state machines run on the host       |

## Tick-Based Execution

Fusion's tick-based simulation ensures deterministic state machine execution across all clients.

### Benefits

* Consistent behavior across all clients
* Rollback support for client-side prediction
* Smooth synchronization even with network latency

## Network Object Setup

Ensure your networked GameObjects have:

1. A **NetworkObject** component
2. A **State Machine Runner** component
3. Proper authority settings on each node

{% hint style="info" %}
For player-controlled state machines, ensure the NetworkObject has **Input Authority** assigned to the controlling player.
{% endhint %}

## See Also

* [Fusion Module Documentation](/game-creator-2/fusion-module)


# PUN2 Integration

Using State Machine 2 with Photon PUN2

When using the [Photon Module 2](/game-creator-2/photon-module-2), State Machine 2 works with PUN2's networking.

## Setup

1. Install [**Photon Module 2**](https://www.ninjutsugames.com/go/photon-module-2?src=docs_state_machine_pun_integration) for Game Creator 2
2. Install **State Machine 2**
3. Network settings automatically appear in node inspectors

## Ownership

* State machines respect PhotonView ownership
* RPCs are sent through the PhotonView component

## PhotonView Configuration

Ensure your networked GameObjects have:

1. A **PhotonView** component
2. A **State Machine Runner** component
3. Correct ownership assigned

### Ownership Transfer

When transferring PhotonView ownership, state machines automatically respect the new owner for nodes set to **Run on Owner**.

{% hint style="warning" %}
Ensure the PhotonView and State Machine Runner are on the same GameObject for proper RPC routing.
{% endhint %}

## RPC Usage

Nodes configured with **RPC** option will:

1. Execute locally on the calling client
2. Send an RPC to all other clients
3. Execute the same node on receiving clients

## See Also

* [Photon Module 2 Documentation](/game-creator-2/photon-module-2)




---

[Next Page](/llms-full.txt/1)

