Godot Version
4.7.stable
Question
The error I’m getting is: Expression is of type “Node” so it can’t be of type “State”.
extends Node
class_name StateMachine
var states : Array[State]
func initialize(_entity : Entity) -> void:
states = []
for c in get_children():
if c is State: # Error here
states.append(c)
In the scene tree, state_machine.gd (see above) is attached to StateMachine (Node) as a child of Player (CharacterBody2D)
StateMachine has one child (Node) with an attached script which extends State
state_machine.gd has no other owners.
I have tried:
- reloading the project
- deleting StateMachine and re-attaching state_machine.gd
- closing all other scenes and scripts, then closing and re-opening godot
- double checking that any and all children of StateMachine have scripts attached which extend State
Any suggestions?