> For the complete documentation index, see [llms.txt](https://smartui-docs.pixelperfectstudio.mx/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://smartui-docs.pixelperfectstudio.mx/miscellaneous-addons/finite-state-machine-plugin-and-behavior.md).

# Finite State Machine Plugin and Behavior

FSM Single Global Plugin

The **Finite State Machine (FSM) Plugin for Construct 3** is a comprehensive solution consisting of **two add-ons**: a **Behavior Add-on for FSM** and a **Global FSM Plugin**. This unique combination empowers developers to manage and control game states with precision, ensuring a seamless and well-structured game flow. Whether you’re creating an RPG, a platformer, or an action-packed shooter, FSM provides the tools needed to keep your game’s logic organized.

### **Key Features:**

* **Two Add-ons for Ultimate Flexibility**:
  * **FSM Behavior Add-on**: This add-on lets you assign FSM states to individual game objects. Each object can have its own specific state machine, providing greater flexibility in managing game logic for specific entities.
  * **FSM Global Plugin**: The Global FSM Plugin manages overall game states, such as GAME\_LOADING, GAME\_READY, GAME\_STARTED, GAME\_PAUSED, and GAME\_COMPLETED. It centralizes control, ensuring consistent game state management across the entire project.
* **Efficient State Management**: Whether managing individual objects or the entire game, FSM allows you to lock game events and behaviors to the active game state. This ensures that certain actions, such as player input, are only permitted when appropriate (e.g., blocking player input during GAME\_LOADING or GAME\_PAUSED).
* **Highly Customizable States**: Both add-ons allow you to define and manage custom game states. You can easily name states based on your game’s design, helping you maintain readability and organization in your code.
* **Seamless Integration**: With FSM, integrating these add-ons into your project is straightforward. Whether you’re using the Behavior Add-on to handle individual game objects or the Global Plugin to control the game’s broader state transitions, both add-ons work together to ensure a cohesive game logic system.

{% hint style="success" %} <mark style="color:green;">**Both addons offer the same ACEs documented in this page.**</mark>
{% endhint %}

## <img src="https://3242409510-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9bZkqK9vYvPkvVDUO4Tp%2Fuploads%2FuhRePKXKT9TZacmLmuhi%2Ficon.svg?alt=media&amp;token=81766450-737d-4dd6-9350-df9a0fbe14fa" alt="" data-size="line">FSM

Finite State Machine Global Plugin for C3 allows you to create and manage global game states to better structure your game events and overall flow.&#x20;

<details>

<summary>Download</summary>

<https://store.pixelperfectstudio.mx/product/fsm/>

</details>

## Actions

***

### `Change State`

Changes the FSM state to the one specified.

| **Parameter**        | **Description**                                                                                                                                                                                                   |
| -------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `State`              | State name                                                                                                                                                                                                        |
| `Ignore Duplicates`  | If checked, the event won't be triggered if the new state is the same as the current one.                                                                                                                         |
| `Complete Next Tick` | If checked, the state change won't be considered finished until the next tick. This means that the 'On State Finished' event won't be triggered and the new state won't be processed until the next tick as well. |

## Conditions

***

### `Compare Current State`

Evaluates if FSM's current state equals the input string

| **Parameter** | **Description** |
| ------------- | --------------- |
| `State`       | State name      |

### `On Any State Changed`

Triggered on any state change.

### `On State Changed`

Triggered when the indicated state is set by the action 'Change State'

| **Parameter** | **Description** |
| ------------- | --------------- |
| `State`       | State name      |

### `On State Finished`

Whenever you change the state of the FSM, the current state is marked as finished and the On Finished state is triggered. The new state won't be processed by this event at this point.

| **Parameter** | **Description** |
| ------------- | --------------- |
| `State`       | State name      |

### `Compare Previous State`

Evaluates if FSM's previous state equals input string

| **Parameter** | **Description** |
| ------------- | --------------- |
| `State`       | State name      |

## Expressions

***

### `GetCurrentState`

Returns the current FSM state

### `GetPreviousState`

Returns the previous FSM state

**(c) Pixel Perfect Studio 2025**
