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

Visual State Machine

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

Quick Information

0 ratings
Visual State Machine icon image
MioKuguisaki
Visual State Machine

A State Nachine whit visual nodes and connections for your game

Supported Engine Version
4.3
Version String
1.0
License Version
MIT
Support Level
community
Modified Date
9 months ago
Git URL
Issue URL
Logo

Node Finite State Machine

A State Nachine whit visual nodes and connections for your game

README Pasted image 20241102164614

State Class Virtual Functions

class_name State extends RefCounted

var _name: String

## Target of state
var target: Node

## Inputs list linked to custom function
var inputs: Array[StateInput]

## Outputs list of the state
var outputs: Array[StateOutput]

## Called when State is created from a State Machine
func _init_state() -> void:
    pass

## Called when the State Machine is Ready
func _on_statemachine_ready() -> void:
    pass

## Called when [StateOutput] is connected
func _on_enter() -> void:
    pass

## Called when any [StateOutput] in state is emited
func _on_exit() -> void:
    pass

## This function executes on each frame of the finite state machine's process
func _process(delta: float) -> void:
    pass

## This function executes on each frame of the finite state machine's physic process
func _physics_process(delta: float) -> void:
    pass

## In case you want to customize how this state handle the 
## inputs in your game this is the place to do that.
func _input(event: InputEvent) -> void:
    pass

Recipe to add a new State Machine

  1. Add into your scene tree StateMachine Node
  2. Create in State script in folder, this script that exteds from State
  3. Create outputs into State
  4. Put script in ScriptList of the StateMachine
  5. Connect the outputs into another state input

Create Inputs for your state

var input = StateInput.new(2, Color.AQUA)
var other_input = StateInput.new(MyEnum.Second, Color(0.5, 0.5, 0.5))

func _init() -> void:
    input.method = method
    other_input.method = other_method
    inputs.append(input)
    inputs.append(other_input) 

func method():
    pass

func other_method():
    pass

Create outputs for your State

var output = StateOutput.new(2, Color.AQUA, "Return To Menu")
var other_output = StateOutput.new(MyEnum.Second, Color(0.5, 0.5, 0.5), output_name)

func _init() -> void:
    inputs.append(output)
    inputs.append(other_output) 

A State Nachine whit visual nodes and connections for your game

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
Visual State Machine icon image
MioKuguisaki
Visual State Machine

A State Nachine whit visual nodes and connections for your game

Supported Engine Version
4.3
Version String
1.0
License Version
MIT
Support Level
community
Modified Date
9 months 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