How to bind a c++ virtual method to gdscript

Godot Version

4.2.x

Question

Hello, I am porting my extension to c++ and I need to mark several functions as virtuals in gdscript.

What I tried

I tried using the BIND_VIRTUAL_METHOD but it does not mark my method as virtual in gdscript.

If I try to create an empty method in the header file called for example _foo, then bind it in the static method _bind_methods as

BIND_VIRTUAL_METHOD(MyClass, _foo)

it does not appear in the methods listed by gdscript.

Could somebody give me a hint? Thanks in advance

1 Like

These issues are related. They all seem to mention using call instead.

Ok, so as a TLDR, it is not possible at the moment without using ugly and fragile workarounds.

Thank you!

1 Like

Yes. BIND_VIRTUAL_METHOD only seems to be used in the godot_cpp bindings and I believe it’s very different from what the engine uses to expose the methods like _ready and _process. If you’re a module developer, you may have more to work with than with GDExtension.