Export another scene that is not a PackedScene

Godot Version



I have a scene with a script and want to use another scene (with script). The other scene is not linked to my current scene.
I tried it with:

@export var testScene: PackedScene

But when I use a scene in this export, I cannot use any varialbes of that scene. For example this is not working:


Is there a way to do this?

1 Like
var my_scene = testScene.instantiate()
print( my_scene.myVariable )
1 Like

Okay, thx. Almost there. But @onready variables are null. So if the testScene contains for example:

@onready var status: Node = $Status

that status will be null on calling. Any idea?

1 Like


var my_scene = testScene.instantiate()
var status = my_scene.get_node("Status")
print( status )
1 Like

It’s because on ready is done when the scene is added to the scene_tree, not just instantiated. You should add your test scene to the tree if you want to use it this way.

1 Like