Godot - Delete a node
This is how to delete a node using GDScript in Godot 4.
You can delete a node using queue_free()
.queue_free()
has the following characteristics:
- Node to delete is itself or specified target
- Deletion is executed at the end of frame processing
target.queue_free()
By removing the child node with the remove_child()
function from the parent element, the node can be deleted within the corresponding frame.
remove_child(target)
target.queue_free()