Override nodes' methods in C++ modules

Godot Version

Godot master branch repo (at the time of topic creation - 4.5 beta 3)

Question

In GDExtension, overriding built-in methods looks like void _process(double p_delta) override;, but in modules it doesn’t work. I found only two topics on this topic, but no one gave any answers (Override _process/_physics_process while in C++ module and Game as c++ engine module? Node inheritance and lifecycle - #11 by YanDaik). The only thing that looked like an answer was a recommendation to use overriding _notification, but this method can’t be overridden either, like _process, _physics_process, _ready and others. It feels like it’s basically impossible to do. Unfortunately, there is no documentation for the source code (or even GDExtension), so all hope is on this forum.

UPD: I’ve figured out some methods and it looks like the _notification way is the right one (it just turned out to be protected so it doesn’t need to be overridden). But I’m not sure about the others (_inputs, _draw). Some methods are declared as virtual, but I’m not sure if it’s still usable the same way as with GDExtension, so I still need a more experienced developer’s opinion.

What does your code look like? overriding with that exact function signature works for me. Is your node registered under the right circumstances?

Actually, it’s technically impossible, because Node doesn’t have a virtual function _process. Only declaration via GDVIRTUAL1(_physics_process, double), but this is more needed by scripts. Are you sure you haven’t mixed up GDExtension and C++ modules? This topic is about modules and custom engine builds :slight_smile:

1 Like

Ah apologies you begin with “in GDExtension” only as an example, I thought that was your problem space; I was speaking about GDExtensions where godot-cpp allows you to override through usual-looking C++. I have not built modules.

1 Like

-------> :eyes:

If you’re rebuilding the engine, you can do whatever you want, including breaking and rewriting stuff! Il
Have fun,
Cheers !