Help with dynamically adding child with multiple child scenes

Godot Version

4.4.1 stable

Question

Hi, I'm working on dynamically adding item into a scene with NavigationRegion2D. I've successfully added item into the first child scene, but when adding item into the second child scene, the item required to have top_level = true in order to see.

I have a scene with 2 child scene. Both these scenes have NavigationRegion2D that have the same config. Root node on both scenes have the same config, no visibility or order config.

Structure of Main Tavern:

Structure of Tavern Basement:

Codes in the Tavern Basement(same in Main Tavern)

extends Node2D
class_name TavernBasement

@onready var navigation_region_2d = $NavigationRegion2D

func _ready() -> void:
	TavernManager.on_request_place_furniture.connect(_do_request_place_furniture)
	TavernNavigationRegionManager.on_request_rebake.connect(_do_request_rebake)
	TavernNavigationRegionManager.request_rebake()
	
func _do_request_place_furniture(furniture: FurnitureItem, location: Global.Location):
	if location != Global.Location.TAVERN_BASEMENT:
		return

	navigation_region_2d.add_child(furniture)

	navigation_region_2d.bake_navigation_polygon()

func _do_request_rebake() -> void:
	navigation_region_2d.bake_navigation_polygon()

The issue is, when i _do_request_place_furniture hit in the MainTavern, I can see its added to the navigation_region_2d and displays and got rebaked, basically works as normal. But if I move down to the Basement and try to place an item there, the _do_request_place_furniture also triggered and do the entire logic correctly. But I cant see it in the game, unless i use this furniture.top_level = true. The issue might not even related to NavigationRegion2D because i have tried adding the item to the root node(TavernBasement), but it still doesn’t show

I’m not sure what the issue is because both of these scene share the same code but it works for the first node in the tree. I tried to recreated everything from scratch but still same issue. Anyone can help me identify the issue or did i config something wrong ?

So the problem is you cant see it unless you set top_level to true?

Do you have a different z-index on any of your nodes or do you have y-sort activated?

Hi, yes i can’t see the item unless i set top_level to true, then it works normally.

I don’t have z-index or y-sort activated on MainTavern or TavernBasement root node, or even the parent node holding those 2. My item has z-index and y-sort enabled though.

I have tried remove the MainTavern and just leave the TavernBasement to see if it’s because of multiple scenes. And it was, if i remove MainTavern out of scene tree, adding item to TavernBasement works normally

It might be the ordering setting Z as relative. It seems like an ordering issue but It could be any one of the nodes that get added to the scene is above your furniture, I would go through everything and just make sure your ordering is sound. I don’t know if you add a child through code if it resets the CanvasItem ordering settings. I would print out the values when you change nodes and see what Z index they are and/or if Z as relative is changed