Hey,
so I was looking into Godots GDNative script feature to use C++ for writing my scripts. I started with the simple example that everyone starts with (a Player
class for KinematicBody2D
) and this worked fine.
Now I've wanted to extend this a little bit by creating an Actor
class, which does the movement and let a Player
class inherit from it to do the user input stuff (this works great with GDScript).
So the first thing I did was to rename the Player class to Actor and created a new class Player:
class Player: public Actor {
private:
GODOT_CLASS(Player, Actor)
public:
void _init() {
godot::Godot::print("Player initialized");
}
static void _register_methods() {
//Actor::_register_methods();
}
};
I've tried with and without Actor::_register_methods();
.
Now when running, "Player initialized" is printed, but the process functions from Actor aren't called. I've changed the class in the scene to Actor to check if something went wrong, but this is still working.
To use the Actor
code I need to register the _process
method and explicitly call the super function:
void _process(float const delta) {
Actor::_process(delta);
}
static void _register_methods() {
godot::register_method("_process", &Player::_process);
}
This of course makes the use of inheritance pretty pointless.
So my question is: Am I doing it wrong or does it simply not work? If I'm not doing it wrong, is this intended behaviour, a bug or simply something that is planned not yet implemented in the GDNative library?