Null export after PackedScene instancing

Godot Version

4.4 Stable

Question

Hello Friends,

I am having a very tricky problem with exported values inside of PackedScenes which I am instancing in order to do level transitions, more specifically a sort of portal/door system in a top down 2D roguelite.

I have created a node that acts as a portal which holds a reference to a PackedScene as an exported value that is then used to load the correct “level” that the portal leads to.

This works fine until looping back to the original area the first portal started in.

Imagine gameplay as follows: Enter portal outdoors, load indoor area, enter portal indoors, load outdoor area. Once in this “outdoor area” The portal that should lead back inside, has a null value where the PackedScene of the indoor area should be. This actually completely broke my project and I had to recover it using version control after trying to exit and reopen the project.

Aside from helping me troubleshoot any strange cyclical dependency problems that might be causing this, is there a better way to do a portal system? I have intentionally chosen to avoid using change_scene_to_packed() because of certain elements I wish to persist between scene transitions, and the option to do deferred loading as well as loading screens later down the line.

You can use strings instead of packedscenes to avoid cyclic dependencies

1 Like

Thanks, I will definitely do something like this in the future. Exported packed scenes are a trauma for me now lol. After some more tinkering my project completely broke again and I had to revert using git once more. I will be staying away from exported values of PackedScene type for the forseeable future!