What is the order of which scripts are executed . .

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By jasperbrooks79

I need a certain script to be executed last, is there a way to set that, it’s not done in order of node tree, top to down . . . Is it alphabetical, or is there a place, where I can see the order . . <3 Thx . .

I mean, last in every frame, so that variables that get passed into are calculated in the correct order <3 :open_mouth: . .

1 Like
:bust_in_silhouette: Reply From: njamster

Most node operations in Godot, such as drawing 2D, processing, or getting notifications are done in tree order. This means that parents and siblings with a lower rank in the tree order will get notified before the current node. (Source)

The further down in the tree a node is, the later its _process()-function will be called. It’s easily verifiable as well: just print something unique in each of your _process-functions and run the scene: what’s printed first is run first.

Okay, thank you . . I did as you said, there is a weird thing, where sub-nodes are called first, backwards, but then nodes after root nodes are called in correct order, and root node, is called last . . . :open_mouth:

jasperbrooks79 | 2020-05-25 15:44

_process is called in tree order, _ready is called in the order you have described to ensure that all child-nodes are available before a node gets ready.

njamster | 2020-05-25 16:08