I needed to know the order things happen inside the Godot engine to better write code for it. I don't think there's something similar in the documentation. There are some pages which can give a grasp but not the whole picture:
I don't know of any more. Since they're scattered I might have missed some.
I've made a very simple diagram by looking at the code, mostly copying from it. I'd be willing to improve it and adding it to the documentation, but I don't know where or how. For now, I want to make sure it's correct and add a bit more info.
Please, add corrections, criticism and any useful info in the comments. Thanks.
If it already existed then I'll feel dumb but don't worry, it didn't take too long.
Processing diagram for Godot 4.3
The scene tree object is an instance of MainLoop. In the default
configuration it's an SceneTree object, thus MainLoop could be replaced by
SceneTree.
Call MainLoop._initialize().
Call DisplayServer::process_events(). Processes window manager events
including input.
Process joystick/gamepad events (only on Linux/udev).
Physics processing step (run as many times as needed).
Flush input buffered events when agile_event_flushing is true (Android only).
Call NOTIFICATION_TRANSFORM_CHANGED on nodes and update physics objects transforms.
Call MainLoop._physics_process().
Send signal SceneTree.physics_frame.
Process object picking.
Call _physics_process() in the scene nodes.
Flush unique calls to groups.
Process timers in physics processing mode.
Process tweens in physics processing mode.
Call NOTIFICATION_TRANSFORM_CHANGED on nodes and update physics objects transforms.
Process queue_delete()/queue_free() calls.
Process deferred calls.
Physics server step.
Flush input buffered events when agile_event_flushing is true (Android only).
Idle processing step.
Call MainLoop._process().
Automatic polling of MultiplayerAPI.
Call NOTIFICATION_TRANSFORM_CHANGED on nodes and update physics objects transforms.
Call _process() in the scene nodes.
Flush unique calls to groups.
Call NOTIFICATION_TRANSFORM_CHANGED on nodes and update physics objects transforms.
Process queue_delete()/queue_free() calls.
Change scene if requested.
Process timers in idle processing mode.
Process tweens in idle processing mode.
Call NOTIFICATION_TRANSFORM_CHANGED on nodes and update physics objects transforms.
Process deferred calls.
Rendering.
Audio update.
Debugger iteration.
Flush input buffered events when agile_event_flushing is false (Android only).
I needed to know the order things happen inside the Godot engine to better write code for it. I don't think there's something similar in the documentation. There are some pages which can give a grasp but not the whole picture:
I don't know of any more. Since they're scattered I might have missed some.
I've made a very simple diagram by looking at the code, mostly copying from it. I'd be willing to improve it and adding it to the documentation, but I don't know where or how. For now, I want to make sure it's correct and add a bit more info.
Please, add corrections, criticism and any useful info in the comments. Thanks.
If it already existed then I'll feel dumb but don't worry, it didn't take too long.
Processing diagram for Godot 4.3
The scene tree object is an instance of
MainLoop
. In the default configuration it's anSceneTree
object, thusMainLoop
could be replaced bySceneTree
.MainLoop._initialize()
.DisplayServer::process_events()
. Processes window manager events including input.agile_event_flushing
is true (Android only).MainLoop._physics_process()
.SceneTree.physics_frame
._physics_process()
in the scene nodes.queue_delete()/queue_free()
calls.agile_event_flushing
is true (Android only).MainLoop._process()
._process()
in the scene nodes.queue_delete()/queue_free()
calls.agile_event_flushing
is false (Android only).MainLoop._finalize()
.