Use this space for questions related to what you're learning. For any other type of support (website, learning platform, payments, etc...) please get in touch using the contact form.
Why do we need a finished signal? Who will emit it?ForkercatHello, I have some questions about the state machine implementation.
My first question is regarding the "finished" signal. Why do we need it? It is mentioned it will be used for wait state; however, it looks like the same logic can be done using a `_time` variable, like we did in LookAtState. So it looks a bit confusing to me and makes me wonder we need it and who will emits the signal. In the example, I didn't see any usage.
My second question is why we use `_physics_process()` in this implementation. Is it because in this module we're dealing with CharacterBody3D? Maybe it'd be good to explain this a bit somewhere.
Some other findings:
1. I cannot test `test_state_machine.gd` because Blackboard.player_global_position is still undefined. I need to comment out the lines first.
2. In `TestState._init()`, we can call `super("Test state", init_mob)` instead of assigning to each member variable.
Thanks!21Sep. 17, 2024
About _on_state_finished()TJIn the implementation of method `_on_state_finished()` it seems that both variables `finished_state` and `current_state` are used. I am confused about why the assertion checks only variable `current_state`. Because afterwards we transition with variable `finished_state`, which could in principle remain unchecked.
Is the assumption perhaps that `finished_state` should always be the current state? But if that is the case, then why would we pass this state as a parameter, since we can always access `current_state` as a property?
Thanks for your help!10Mar. 12, 2025
trigger_event() does not use assert()ram876Hello! The place where the logic of trigger_event() is explained says that "We use an assert for the state". But assert() is not present in its code. Is there some kind of mistake?10Jan. 30, 2025
Typo in sample codeRuben TeijeiroThe following sample code has a typo. Instead **SateName** it should be **StateName**
> var state := State.new("SateName", mob)10Dec. 13, 2024
Virtual class glossary typosRuben TeijeiroI didn't find any other place to report this but I found some mistakes in the Virtual class glossary page: [https://school.gdquest.com/glossary/virtual_class](https://school.gdquest.com/glossary/virtual_class)
It mentions the disappear() function when it should be the destroy() function.10Dec. 13, 2024
There's a bug in the state machine activation logic01_edicts_knurledset_physics_process is set to false in init(), however, since physics_process() is overridden set_physics_process is set back to true before ready() is called. As a result, the state machine is activated immediately on ready() instead of waiting to be activated.
There's a note in the documentation about it:
> **Note:** If [_physics_process](https://docs.godotengine.org/en/stable/classes/class_node.html#class-node-private-method-physics-process) is overridden, this will be automatically enabled before [_ready](https://docs.godotengine.org/en/stable/classes/class_node.html#class-node-private-method-ready) is called.
You can fix the issue by moving set_physics_process(false) from _init() to _ready()10Dec. 03, 2024
Lesson Q&A
Use this space for questions related to what you're learning. For any other type of support (website, learning platform, payments, etc...) please get in touch using the contact form.