• Godot HelpC++
  • GDExtension add_child, child Node not show in Scene Tree

I’m experiencing an issue where a Child Node is not showing up in the Scene Tree in Godot. The Child Node is created and added to the Scene Tree using the add_child() function, but it’s not visible in the Scene Tree. How to fix it!

  • xyz replied to this.

    tuanpv Print get_owner(). It may be null in which case the node won't show up in the editor.

      xyz get_owner() return 0
      node->set_owner(get_tree()->get_edited_scene_root()) it work ok :

      • xyz replied to this.

        tuanpv Note that your _ready() is called at runtime as well in which case SceneTree::get_edited_scene_root() will itself likely return null. So be aware of that if owner is important for your application at runtime. To differentiate if you're running in editor or not use Engine::is_editor_hint().

        2 months later

        I have the same. I noticed that the child node only shows up after running the code and switching from local to remote. The same behavior also occurs when you code the same thing in GDScript, so I guess it's expected behavior.