How to call gdextension method in gdscript?

Godot Version

4.2.2

Question

I have successfully built my GDextension module and am able to add my custom node to a godot project. The problem I’m encountering occurs when I try to call any of the public methods I have bound and exposed to the inspector.

When I right click my node and view the documentation I can see the binded methods, so I’m pretty sure I have exposed them correctly.

However, when I try to call one of these methods using self.calibrate_camera(img_dir) with a script attached to my custom node I get the error “Function calibrate_camera() not found in base self.”
Here is the line where i bind the method:

ClassDB::bind_method(D_METHOD("calibrate_camera", "image directory"), &CalibratedCamera::CalibrateCamera);

and the function header:

void CalibratedCamera::CalibrateCamera(const godot::String imageDir)

Do I have to call the method another way? Perhaps using self.call()

Does the script extend from your GDExtension class? Can you show the gd script? Having spaces in the parameter name is odd, try changing to image_directory

I hadn’t realized that my gdscript had to extend the GDextension, but that makes perfect sense. Thank you so much!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.