Instantiating new scenes in one function

Godot Version

Godot 4.7

Question

Unity dev here, switching to Godot and using C#.
I’m creating a function that procedurally generates a dungeon (think something like Binding of Isaac) and the function works by instantiating a whole bunch of room scenes to create the dungeon (and instantiates enemies to fill them as well). It does this all in the same function, which is called in _Ready(). In Unity, this would be super straightforward, but when I try this in Godot, it gives me the error Parent node is busy setting up children, 'add_child()' failed. Consider using add_child.call_deferred() instead. I’m not exactly sure how call_deferred works in C#, or why this error is happening. Help would be appreciated!

There is a C# example using call_deferred with the method name

In your case I believe this snippet would work

node.CallDeferred(Node.MethodName.AddChild, new_child_node);