Hi! I'm trying to migrate a very small project to 4.0 from 3.5.1. My problem is likely with my project structure as opposed to 4.0 newness. I have a node with this hierarchy:
Entity
|_ AnimationContainer
|_FSM
The FSM holds a bunch of state resources with one active state & the _physics_process, _process, _input etc functions on the FSM simply call events from the state like active_state.handle_input(event) which is a virtual function in every state that can handle input however it wants.
FSM also exports a dictionary of the format { "State Name" : StateResourceObject.gd } so I can add and edit states on the fly from the gui. The problem is the FSM _ready function.
Here's the relevant code from the FSM's ready in 3.5.1 that worked:
entity = get_parent()
yield(owner, "ready")
for key in states.keys():
states[key].initialize()
state = states[start_state]
state.enter()
However 3.5.1 was handling the instantiation of children meant this worked no problem. The issue with 4.0 arises because FSM is "readying" before both my AnimationContainer and Entity, so basically it called the initialize function in every state before the animations are ready, so sometimes crashes when it attempts to start an animation because the scripts and systems in my AnimationContainer are not ready yet. Similarly, the entity was being "ready" before the AnimationContainer, and so the initial call (inside entity.ready) to my animation system (anim_container.set_anim("idle", "default")) would error out because the dictionary for these animations has not been constructed by the AnimContainer's ready function.
I fixed that problem by calling await anim_container.ready to the entity ready function, but calling await entity.ready/owner.ready inside the FSM does not prevent the FSM from getting ready before the AnimationContainer for some reason. I tried changing the FSM ready function to a function i explicitly call from entity's _ready function (after the await anim_contianer.ready) but then the input and physics functions in the FSM execute before the states are ready, meaning when it calls current_state.physics() it crashes because the current_state variable has not been set up by the fsm set up function.
I could probably do something like preload and instantiate these things through code but I like the visual ability of things like the FSM and its state resources. Does anyone have any suggestions on how to fix this?