All Questions

Community

indbal
posted to: The Idle state

Why don't we need move.physics_process(delta) at 5:50?

Hi,


I'm trying to understand why do we delete move.physics_process(delta) at 5:50. As far as I understand in the code(script) Idle extends State, and Move also extends State. But Move has Idle as children, which is not inheritance in Godot, right? It only means Move [has an] Idle node as "children" (like a member pointer to the Idle object). And as Idle doesn't extend Move, it doesn't overwrite Move.physics_process(). Am I missing something here?

  • Nathan Lovato replied
    Solution

    I just rewatched it. The reason I said that is because when you make a hierarchical state machine, there's the expectation that there is some kind of inheritance and the parent states' update may run by default. That's because the typical implementation in a object-oriented programming uses inheritance.

    If I recall correctly, all other states that are children of the Move node will use the parent's code to move. Idle is the exception.

    I see now how that's confusing as, indeed, we don't use GDScript's extends keyword.

  • indbal replied

    Thanks for the quick answer, now it is clear. :)