Is it a bad idea to leave Orphan nodes hanging around if I keep track of them?

Godot Version

Any

Question

I had posted a long question before, if anyone wants full context feel free to dig the post I made few days ago, I’m just trying to figure out if a potential solution is viable here.

Basically, I was dealing with a level switcher.
The problem is: Godot insists a static body should have collision, even if it’s hidden from canvas or outright process disabled.
With this, I can’t stack TileMap and simply hide and show them on demand, Player will be blocked by invisible levels. Wipe out the collision would also cause the current level dysfunctional since they shared the same property.

And it just hit me.
What if, I just get all the children under a node, put them inside an array, de-parent all of them, and add_child() them back on demand?
…Upon testing, It created more problem and didn’t solve much.
Somehow the custom scene tile got duplicated, enemy still respawns upon level switching, but not the duplicate one. It just doesn’t get alone with TileMap, I guess.

Anyway, my question is:
What’s the risk of this “Make them orphan until need them” approach?
This looks like a possible route, but it might has some serious drawback or potential problem that it’s not worth keeping digging.
What’s your take on it? Thanks for reading.

Apart from performance lost and memory leaks I don’t see any obvious drawbacks of orphan nodes.

1 Like

I haven’t worked with tilemaps in detail yet, but can you have two Physics Layers, one that has collisions for those tiles, and one that doesn’t, and switch between which layer is active?

Not sure if all physics layers must be active for a tile at once or can be switched, but figured I’d share anyway.

I’d imaging it’d only work if I can port an entire layer into another layer, or I’d need to have a layer for every single level existed