I have this function to remove node from the world when dead, it is called from the unit that is being killed:
func kill_unit(this_unit : Unit):
left_click.disconnect(this_unit.set_target_coords)
remove_child(this_unit)
this_unit.queue_free()
update_all_units()
But when the unit actually dies, I get this crash:
Condition "p_child->data.parent != this" is true.
<C++ Source> scene/main/node.cpp:1719 @ remove_child()
How should I do things properly? I mean, removing a node from the tree should be a pretty trivial thing...
remove_child() seems required here because I rebuild the order of units by parsing all children, and turn order seems to belong to the unit that is already queued free, but not removed yet.