Godot Version
4.4
Question
I have a Singleton PlayerInventory
script, which holds an array Equipment = Array[Item]
of some custom Item
objects. When I move between Scenes however, I see the Equipment
array automatically queue_free()s all the objects in the array, making them inaccessible.
Is this supposed to happen with objects in Autoloads, or am I screwing something up? And if so, is there a way to prevent those custom Item
objects from being freed?
I do kind of have a solution - my Item
s get their data from an ItemResource
resource, and I know I can transfer the equipment data between scenes if the Equipment
is instead made to be an Array[ItemResource]
. Then I could theoretically use that data to instantiate everything as I need.
However, this will complicate a LOT of things and require me to refactor a huge portion of my project. Before I do all that, I just wanted to do my due diligence and check - can I carry my array of custom objects across scenes with an Autoload? Or is my only path forward slogging through that big refactor? Any tips would be really appreciated