_ready / _init, nodes accessabiliity

_init() is what’s typically known as a constructor. It runs when an object is first created. In my opinion, you should rarely use it, and only if you are creating the object in code. It runs before the object is fully constructed, and before it has been added to the scene tree. So it is mainly used to initialize objects (“init” is short for initialize).

_ready is a function used to setup an object before it is ready to be used. The name can be misleading, as it doesn’t mean that the object is ready, but that it is getting ready. It is kind of a second step initializer. Unlike init(), it doesn’t take arguments.

_ready() delays itself until all children of the object have been created. This allows you to initialize things using the child objects of the node.

Once an object is fully created, it triggers the ready signal.

4 Likes