- Edited
So let's say I am instancing a scene.
First I do this.
onready var Robot = load("res://Robot.tscn")
Then we do step 2:
func _on_Button_pressed():
var b = Robot.instance()
var p = position
b.position = p
get_node("..").add_child(b)
This all works fine and is making the instanced scene Robot.tscn appear on the object this script is attached to (an Area2D, if that matters). Now I want to delete that instanced scene elsewhere in this same script when pressing another button.
How do I delete that instanced scene now, from within the scene it was brought into?
This does not work:
get_node("../b").queue_free()
Nor does this:
b.get_node("..").queue_free()
And this doesn't work either:
b.queue_free()
Robot.queue_free() also doesn't seem to work, and free() on its own also doesn't work in any of the above.
How do I delete an instanced scene from the scene that I generated it into? And how do I path to the instanced scene otherwise for other purposes?