So I've only been using Godot for maybe a week so forgive my ignorance. I do, however, have quite a bit of experience in other game engines (mainly UE4) so I'm not totally stupid. Anyway, I'm trying to make an inventory system for my game and it'll work perfectly the first time the game is run. However, the next time I run the game, it throws an error saying

Attempt to call function 'get' in base 'previously freed instance' on a null instance.

Here's the code if you want to give it a look. I assume its problem is that it's not totally freed from memory until it does throw that error as to not crash the editor or whatever.

  • queue_free() it's in the name: it queues the freeing to the next safe idle frame or so. It doesn't immediately free the resource.

Seems to be some sort of editor bug. If I give it some time after running the scene, launching it again spits out no error messages.

My first suggestion would be to not add anything to the inventory until the _ready() function is called by the engine.

    cybereality it’s the function parameter, which I use to pass in a node called “TestItem” whenever the player looks at the item and presses the interaction key to pick it up

    Can you show the code that calls that function? It seems like an odd design to pass a parameter into a function and then delete it. Particularly if that variable reference is saved or existing elsewhere.

      cybereality that’s how most games do it. There’s no need for it to take up all those resources being in 3D space when all I need are it’s values.

        Erich_L well it’s in its own function so it’s not called until it’s needed, which is way after the _ready function is called

        StunkInLiguine I’m not sure that logic will work in Godot, queue_free does not translate directly to it being null as far as I know.

        queue_free() it's in the name: it queues the freeing to the next safe idle frame or so. It doesn't immediately free the resource.