I have a GDNative class that looks like this:
class Level : public godot::Node2D {
GODOT_CLASS(Level, godot::Node2D);
public:
Level() {}
void _init();
void _ready();
void _physicsProcess();
private:
godot::TileMap* m_tilemap = nullptr;
int m_foobar;
public:
static void _register_methods() {
using namespace godot;
register_method("_ready", &Level::_ready);
register_method("_physicsProcess", &Level::_physicsProcess);
register_property<Level, int>("base/foobar", &Level::m_foobar, 16);
}
};
How can I pass a tilemap to Level from the Godot editor?
Things I've tried so far:
register_property<Level, TileMap*>("base/tilemap", &Level::m_tilemap, nullptr);
The property shows up in the editor, but I can't edit it.
- Calling
get_node("TileMap")
from _ready()
: returns a Node, not a Tilemap, and dynamic_cast doesn't work because Node has no vtable.
Is there a template equivalent to Node::get_node()
? Or is the only solution to use a reinterpret_cast?