Override _process/_physics_process while in C++ module

Godot Version

4.3

Question

Hello!

I want to support custom _process/_physics_process behavior for subclass of Node3D for both

  1. GDExtension

  2. C++ module

  3. In GDExtension I just need to declare void _physics_process(double delta) override and define it. It works as expected.

  4. I can’t do the same for C++ module though: _physics_process is GDVIRTUAL1 in godot’s node.h header and not virtual. What I tried:

  • Use
    set_physics_process(true);
    set_process(true);
    SceneTree::get_singleton()->physics_process(0.05);
    SceneTree::get_singleton()->process(0.05);

After these calls I successfully get “true” from “is_processing()” and “is_physics_processing()” but get 0 from “get_process_delta_time()” and “get_physics_process_delta_time()”.

  • I also tried to add GDVIRTUAL_BIND(_physics_process, “0.05”) in _bind_methods: it compiles but no code from _physics_process is called.

Any suggestion is appreciated.

You use _notification, this isn’t a virtual method in modules

1 Like

Thank you a lot for tip! I will try again.

1 Like