Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Cobra! | |
Old Version | Published before Godot 3 was released. |
I’m trying to make come objects get destroyed by code, so certain levels will only have the objects it needs, and doesn’t need to compute objects it doesn’t.
However, after triple checking I got the nodepaths correct, the objects just aren’t getting destroyed.
Here’s the (relevant) code:
export(Array) var itemsToDelete
func _ready():
if itemsToDelete.size() > 0:
for item in itemsToDelete:
print(item)
get_node(item).free()
What do I do? I’m using Godot 2.1, by the way.
use queue_free()
instead
using free
can cause errors unless you REALLY know what you are doing and queue_free()
makes the object disappear in the end of its usage(aka end of scene)
rustyStriker | 2018-01-09 15:29