Connecting to physics_frame internally in GDExention

Godot Version

4.1.3 / 4.2.1


Working on a GDExtension where we need to connect to the physics_frame or process_frame inside the extension. With the module version, we just do:

auto callbacks = callable_mp(Steam::singleton, &Steam::run_callbacks);
SceneTree::get_singleton()->connect(“process_frame”, callbacks);

However, SceneTree does not have a get_singleton() function and callable_mp does not exist. I seem to be able to connect to Engine’s get_singleton() but can’t seem to get the connection to work.

Any ideas?

1 Like

Elaborate? SceneTree can be accessed via get_tree() and callable_mp exists.

Hey there! callable_mp does exist in 4.2.1’s version of godot-cpp but I can’t find any reference of it in 4.1.3’s. I do see that node.hpp does have get_tree().

I was hoping to have a solution that fit both versions. I can cobble together some tests tomorrow and see if I can make progress with this information. Cheers!

1 Like

I was wrong about callable_mp’s existence in that version. It was only exposed recently in GDExtension.

1 Like

I’ll see if I can get that all working in 4.2.1 at least then try to figure out something for 4.1.3. Surely I can use connect in some manner in that version.