I am trying to add a bunch of nodes I create at runtime, but I can't get it to work. I know this is a duplicate question, but all the methods I found here and elsewhere didn't work, furthermore, the geteditedscene_root() method returns Nil.
So here's what I tried so far, following the suggestions from this Q&A page:
Create a new node: var newNode = Spatial.new()
Get the current scene root to add it there: var scene =
Add the child: scene.add_child(newNode)
Set owner: newNode.set_owner(scene)
It doesn't matter if I set the owner before or after adding the child, it just doesn't work. As you might have guessed I am working in the 3D editor, but that shouldn't make a difference I hope.
Since gettree().geteditedsceneroot() returns Nil, I have tried some other ways with no luck, like gettree().getroot().getchild(0) and gettree().getcurrentscene()
What are your thoughts about this? btw, I'm using Godot 2.1.3.