![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | sava13331 |
If I remove one node from the array, it is replaced by “deleted object”. How to solve this problem?
![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | sava13331 |
If I remove one node from the array, it is replaced by “deleted object”. How to solve this problem?
![]() |
Reply From: | Bean_of_all_Beans |
Based on you saying that “Deleted Object” is replacing the nodes you removed from the array, it seems you are either calling Node.queue_free()
or Node.free()
at some point, then later try and access it in some way. When a Node is freed, any reference to it will only return “Deleted Object”.
To truly remove the Node from the array, call array.remove(node_index)
, where array
is your array of Nodes, and node_index
is the index of the Node in the array (starting from 0
and going up to array.size() - 1
).
So if you are freeing your Nodes, try adding:
# i is the index of the Node you are removing
node_array[i].queue_free()
node_array.remove(i)
This will first queue the node you want removed to be removed from the Scene Tree, then will remove it from the node array. Your node array will shrink by one (or however many nodes you are removing), but it will get rid of those “Deleted Object”'s you keep seeing.