This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
0 votes

I have a GDNative class that looks like this:

class Level : public godot::Node2D {
  GODOT_CLASS(Level, godot::Node2D);
  Level() {}
  void _init();
  void _ready();
  void _physicsProcess();

  godot::TileMap* m_tilemap = nullptr;
  int m_foobar;

  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?

in Engine by (12 points)

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.