How to remove a node with child objects from a scene, but not remove it from memory and a variable

Godot Version 4.1.1

I need to create a canvas scene from another node in the world for the game. In order for it to be created many times, I need to remove it from the player's canvas, but not remove it from the variable of the second node.

Question

How to do it? QueueFree doesn't help - it removes the node from memory and the scene.

reparent? I’m not sure I understand the situation fully.

You can remove a node from the tree, that will keep variables mostly-functional.

get_parent().remove_child(self)

I’m not sure what “the second node” is in this case.


maybe you need to use duplicate too?

Perhaps, thanks for the answer, but I have already solved this problem by creating an identical object, although it would probably be more convenient to do this using duplicate, but okay. Thank you very much for the offer!

  1. Remove from scene:
    Removing the node from its parent node should cause it to stop receiving signals from the main scenetree and therefore stop updating/rendering.
  2. Keep loaded:
    As long as you maintain a variable referencing the node, it should keep it loaded.