How can I draw information of a node to a Texture?

I’m using godot 4. I have a character node, for now only with a SpriteNode2D, but i want to create more nodes to it; and i need to draw it to a texture to use in UI, the character needs to exist in world, can’t be copied or reparented. I tried to use Viewports, but I always need to reparent the character and he disappear from the normal world, showing only in the viewport

So if I understand correctly:
You have this layout:
→ Characterbody2d
---->sprite2d

And you want to add more nodes so it looks like this:
→ Characterbody2d
---->sprite2d
---->sprite2d
---->sprite2d
---->sprite2d
---->sprite2d

Then, you have some kind of UI menu and you want to show the player, where he is shown as he is in the game, with all sprites combined to show a composite sprite.

I assume your scene has a CanvasItem to hold your UI menu controls. If the menu is in the same scene as the player, you can reference the player from your UI script by dragging the player node into the script.

Then, you can :

  1. loop over the player’s children
  2. for each child, create TextureRect.new() and copy the texture from the SPrite2d to the TextureRect
  3. position the TextureRect into your UI as needed.

If I got something wrong, provide more details and show your scene layout.