Visual State Machine
by MioKuguisaki
44
Node Finite State Machine
A State Nachine whit visual nodes and connections for your game
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
- Add into your scene tree StateMachine Node
- Create in State script in folder, this script that exteds from
State
- Create outputs into State
- Put script in ScriptList of the StateMachine
- 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)
Download
Version1.0
Download Now
Support
If you need help or have questions about this plugin, please contact the author.
Contact Author