This is how I solved it. I hope it does not cost much performance.
extends Spatial
var camerra
var isCameraOn = false
func _ready():
camerra = Camera.new()
add_child(camerra)
func _physics_process(delta):
if !isCameraOn:
remove_child(camerra)
get_parent().add_child(camerra)
isCameraOn = true
yield()
commented by @Magso also works. Maybe it works even better than this. I just wanted to let know this is what I am using.
Update:
Turns out there is an error which I did not notice before. There is also an advice in the Debugger.
add_child: Parent node is busy setting up children, add_node() failed. Consider using call_deferred("add_child", child) instead.
So, the working code I am currently using is:
extends Spatial
var camerra
var isCameraOn = false
func _ready():
camerra = Camera.new()
get_parent().call_deferred("add_child", (camerra))