`_physics_process` super call occurs automatically?

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

I noticed that if I have a gd script, which is then extended by another gd script where both define a _physics_process function, the extending script automatically calls the super version of _physics_process. Based on this GitHub issue, I would expect the super version to be called only when I explicitly call it with ._physics_process(). As this seems to not be the case, I have a few questions about this. Do all functions automatically call their super versions? If not, which functions do call their super versions? Why do they call their super versions? Lastly, is there a way not to call the super version?

Godot 4 update: it’s not the case anymore, see Reddit - Dive into anything

Hyper Sonic | 2023-02-17 17:31

:bust_in_silhouette: Reply From: Zylann

In general, functions are called the way you would expect. However, some functions (such as _process or _physics_process are called by the engine using call_multilevel, which means it will call each method of the class hierarchy.
I am not sure what was the intent behind this, it’s as if engine writers wanted to “simplify” the work of the script writers when inheritance is used, but personally I find it confusing because it is basically an exceptional and uncontrolled behavior.

This is pretty close to what I expected. Do you happen to know if there’s a list of functions that do this? And also if you can choose not to do this with these functions? I’m guessing you can’t choose not to, as the reason these ones do preform this multilevel call is because it’s a workaround to make them work, but if you happen to know otherwise, that would be great. Thank you!

shianiawhite | 2018-08-21 19:44

After doing a quick search in the source code, I found these methods are called this way:


There is also _set, _get and _get_property_list mentionned in the doc: Object class — Godot Engine (3.0) documentation in English

Maybe also _init? Or even all special methods starting with _

There was a discussion about this system a while ago, then the author closed the issue… even though more people added to the conversation afterwards ^^"
Gdscript: It's impossible to override _process function · Issue #6500 · godotengine/godot · GitHub

Zylann | 2018-08-21 20:16

the same for _ready

chiara_jm | 2020-04-05 21:05

In the Github thread, reduz commented on Sep 15, 2016:

callbacks get called at all levels, back when we had Squirrel
programmers used to forget calling the parent functions all the time
for callbacks they handled different and it was kind of a mess.

I’ve worked with an in-house game engine written in C++, and for some functions, forgetting to call the base implementation resulted in very bad behavior. Maybe the Godot engine devs made this design choice simply to avoid such situations?

placroix74 | 2022-10-13 02:13