All Questions



no autocompletion of state ?

When coding the StateMachine Godot did not autocomplete the list for methods from the state-node.

To do so the line:

onready var state: = get_node(initial_state) setget set_state

can be changed to

onready var state: = get_node(initial_state) as State setget set_state.

(Casting directly to state, as get_node() only returns an object of type Node.

  • Nathan Lovato replied

    For Godot to infer the type of the node you're getting, you need to have the corresponding scene open in your editor.

    In other words, something like this:

    onready var node := $SomeNode

    Should give you the right completion when the scene is open on top of the script.

    To make it always work you can either specify the type (if it doesn't cause cyclic issues) or, as you did, use casting.