Check out our latest project ✨ OpenChapter.io: free ebooks the way its meant to be 📖

Programmatic State Machine

An asset by VioletGames
The page banner background of a mountain and forest
Programmatic State Machine hero image

Quick Information

0 ratings
Programmatic State Machine icon image
VioletGames
Programmatic State Machine

A simple state machine for Godot defined solely in codeCreate a StateMachine and add states to it. Pass your own functions to a state to execute code on enter, process, physics process, and exit calls. Transfer states with one function call.For more information see the README

Supported Engine Version
4.4
Version String
1.0.1
License Version
MIT
Support Level
community
Modified Date
8 hours ago
Git URL
Issue URL

Programmatic State Machine

A simple state machine for Godot defined solely in code

This plugin defines two classes: State and StateMachine

Create a new StateMachine by defining a variable:

var state_m = StateMachine.create(self)

Add states by calling:

state_m.add_state("State Name", enter_func, process_func, physics_process_func, exit_func)

transfer between states using:

state_m.transfer("StateName")

The state machine will automatically handle state transitions and call the correct functions.

State Dependency

State dependencies are created to handle state transfers during asynchronous transfer calls.

To create a dependency, get the current state ID and save it to a variable. In the transfer call, pass the saved state ID as a parameter.

var state_id = state_m.get_current_state_id()

await get_tree().create_timer(1.0).timeout

state_m.transfer("NextState", state_id)

For a more in-depth example, see StateMachineExample.tscn

A simple state machine for Godot defined solely in code

Create a StateMachine and add states to it. Pass your own functions to a state to execute code on enter, process, physics process, and exit calls. Transfer states with one function call.

For more information see the README

Reviews

0 ratings

Your Rating

Headline must be at least 3 characters but not more than 50
Review must be at least 5 characters but not more than 500
Please sign in to add a review

Quick Information

0 ratings
Programmatic State Machine icon image
VioletGames
Programmatic State Machine

A simple state machine for Godot defined solely in codeCreate a StateMachine and add states to it. Pass your own functions to a state to execute code on enter, process, physics process, and exit calls. Transfer states with one function call.For more information see the README

Supported Engine Version
4.4
Version String
1.0.1
License Version
MIT
Support Level
community
Modified Date
8 hours ago
Git URL
Issue URL

Open Source

Released under the AGPLv3 license

Plug and Play

Browse assets directly from Godot

Community Driven

Created by developers for developers