Have the signal and state script to connect on the child transition

watching a tutorial for fps making
link: https://www.youtube.com/watch?v=VtJXqRsFezY
its stating I’m calling a nonexistent function “connect” in base signal
problem code line will be bolded/line 12

code:
class_name StateMachine

extends Node

@export var CURRENT_STATE : State
var states: Dictionary = {}

func _ready():
for child in get_children():
if child is State:
states[child.name] = child
child.transition.conncet(on_child_transition)
else:
push_warning(“StateMachine contains incompatible child node”)

CURRENT_STATE.enter()

func _process(delta):
CURRENT_STATE.update(delta)
Global.debug.add_property(“Current State”, CURRENT_STATE.name,1)

func _physics_process(delta):
CURRENT_STATE.phyics_update(delta)

func on_child_transition(new_state_name: StringName) → void:
var new_state = states.get(new_state_name)
if new_state != null:
if new_state != CURRENT_STATE:
CURRENT_STATE.exit()
new_state.enter()
CURRENT_STATE = new_state
else:
push_warning(“State Does Not Exist”)

this also crashes the game on launch.

“Conncet” is spelled wrong, ironically you spelled it correctly typing out the error message.


By crashes do you mean it opens a stack trace? This will freeze the game so you can inspect the game’s state at the point of failure using the debug panel. It is not a crash, but if you try to close the window most operating systems will treat it as frozen.


Make sure to paste scripts with proper formatting

1 Like

oh okay thank you, sorry