All Questions


Eduardo Assis

Calling `process_` function with undefined `state` variable.

In the StateMachine script, when the engine calls `_process`, can occur the `state` variable not be properly initialized yet causing an error, no?

  • Nathan Lovato replied

    You shouldn't have that error, no.

    If you get the "undefined variable" error, you'll need to double-check that you didn't make a typo writing the variable. This error happens when a variable is not defined or there is a typo in your code.

    Could you double-check that and let me know if this helps?

  • Eduardo Assis replied

    Oh, it's just curiosity. Sometimes I get errors like that.

    The engine waits the "ready" signal to start cycling through functions like "_process()"/"_physics_process()"? I never understood this part right.

  • Nathan Lovato replied

    Yes, Godot will first call _ready() when adding a node to the scene tree, and after that start calling _process() and _physics_process() when processing frames.