derkork / godot-statecharts

A state charts extension for Godot 4
MIT License
761 stars 39 forks source link

Getting several error messages on running the game without any bugs or unintended effects. #137

Closed Doomhardt closed 1 month ago

Doomhardt commented 1 month ago

I'm using a 'DirectionControl' Compound State Node as a way to know which direction the player is facing and playing the appropriate animation for it in my top down game. Whenever I run the game I get about 20 error messages for each of the transitions (this one is for Horizontal Middle to Down on the Horizontal Axis) though occasionally I get about 40. The game still runs perfectly fine.

E 0:00:00:0871 expression_util.gd:19 @ evaluate_expression(): (guard in /root/World/Player/StateChart/Root/DirectionControl/Horizontal Axis/HMid/To Down) Expression execute error: self can't be used because instance is null (not passed) for expression: input_direction.x > -0.85 <C++ Source> core/variant/variant_utility.cpp:1091 @ push_error()

expression_util.gd:19 @ evaluate_expression() expression_guard.gd:18 @ is_satisfied() all_of_guard.gd:13 @ is_satisfied() transition.gd:74 @ evaluate_guard() state_chart_state.gd:115 @ _state_enter() compound_state.gd:65 @ _state_enter() parallel_state.gd:68 @ _state_enter() parallel_state.gd:68 @ _state_enter()
derkork commented 1 month ago

This looks like the expression guards are using expression properties which are not yet set when the guard evaluates. So you will need to set some initial values for your expression properties. You can either do this using set_expression_property inside of a _ready function, or starting with version 0.16.0 you can also use the inspector for this:

image

Doomhardt commented 1 month ago

It works without any errors now, thank you

derkork commented 1 month ago

Great, thanks for reporting back!