I’m encountering an issue when using add_child to load a scene.
func _switch_to(room_scene: PackedScene) -> void:
if current_scene:
current_scene.queue_free()
current_scene = room_scene.instantiate()
scene_layer.add_child(current_scene)
As shown in the code, I’m trying to load the scene by replacing the child node. This is because my project uses a SubViewport node to display a 2D camera window, allowing the game view and UI to coexist.
However, I’m running into a problem. If I instantiate the scene directly:
The
GameObject can be interacted with normally.
But if I add the scene via code:
The
GameObject cannot be interacted with properly.
The collision settings haven’t changed during this process; the only difference is the loading method. Could someone advise on how to resolve this issue?





