I have a building game and I want to queue_free() the object I click, but when I try, every instance disappears. How do I solve that?
Hard to say without seeing some code. Post the code in question.
jgodfrey | 2023-03-13 02:20
Try adding an Area2D with an CollisionShape2D to the buildings. Then connect the input_event signal from the Area2D to a script that is attached to the building. In there do your logic as you need and try
Area2D
CollisionShape2D
input_event
func _on_area_2d_input_event(viewport: Node, event: InputEvent, shape_idx: int) -> void: if Input.is_mouse_button_pressed(MOUSE_BUTTON_LEFT): self.queue_free()
Hope this works