Godot Version
v4.2.2
Question
So i make a list in the same script that contains info from all the nodes we make and automaticly generate.
static List<ClassTile> instances = new List<ClassTile>();
private Node3D _instance;
private String _id;
private Vector3 _position;
public ClassTile(String id, Node3D instance, Vector3 position)
{
_instance = instance;
_id = id;
_position = position;
}
I am placing them in the map with AddChildDeferred.
private void AddChildDeferred(Node node)
{
CallDeferred("add_child", node);
}
But i can’t find out how to delete a certain node that is in the list. I found out wich one that i want deleted at a certain time.
Now the trouble is getting rid of that certain tile. I’ve tried a lot of diffrent things that i thougt might work. I searched for it online but i can’t seem te find out what i need. For example i tried:
private void RemoveChildDeferred(Node node)
{
CallDeferred("remove_child", node);
}
But then i get this error :
E 0:00:08:0973 remove_child: Condition "p_child->data.parent != this" is true.
<C++ Source> scene/main/node.cpp:1450 @ remove_child()
i also tried this and some other things
i.GetInstance().GetParent().RemoveChild(i)
And i tried a few other methods but maybe i did something wrong. I would appreciate it if u could help, thanks.
(Random thought but is there a way to delete a node bases on the cords, even it is not in the list)