0 votes

I'm working on a Dwarf-Fortress type game that goes through a proc-gen world creation before you play.

It creates npc's , items etc.
The npc's are instance of a Being scene.
The items are resources, not actual scenes.

In the world creation scene - I create the instances, but I don't actually add them to the scene, I just put them in a list so I can loop through them.

As the world creation loops - I've found it's not safe for me to be queue_free-ing these in my main loop.... so I add them to a list in autoload called: "gamelistofobjectstoqueuefree".

When it's more safe to do so... I then loop through the Autoload.gamelistofobjectstoqueuefree list, and try to queuefree each item in the list.
But I get error : " Attempt to call function 'queue
free' in base 'null instance' on a null instance. "

Any idea why I wouldn't be able to queue_free from a list I'm keeping in an Autoload/Global/Singleton script?

Also - how do I handle the items, which are resources, not Scenes at all. Can I queue_free a resource?

Godot version 3
in Engine by (133 points)

1 Answer

+1 vote
Best answer

Hi
the error tells you that there is no object referenced in the list. Maybe you want to make a breakpoint there and analyse the properties you are refereing to.

For the resources ... godot resources are reference counted. That means if there is no more reference pointing to the object they automaticaly get released/deleted.

by (4,068 points)
selected by

Marked as answer. I took a closer look. I was queue_free-ing just fine, after reading your response I went back and realized - I wasn't also removing that object from the list, hence the error. Doh. Thanks for your help.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.