So, I have Tilemaps and a mob(creature) class derived from Sprite, and I want to load up a new random dungeon Tilemap and move that mob from the current map to the newly created map.

I can get it to work error free, but there are issues. I am removing it as a child from its parent, then I tried adding it as a child to the new map, that did not work, because afterwards the Sprite no longer functioned(ie won't update position with SetPosition(), it will 'show' the sprite, but at its old position where the old map was which I deleted with QueueFree()).
It shows it correctly attached as a child to the map.

Right now I work around it by saving my mobs and loading a new instance of them on the new map, that works fine, and is only me commenting out the previous addChild/SetOwner lines and doing the save/load. What is happening when I reparent a node that would not let it function anymore after being attached to a new node?

I haven't really had to re-parent nodes before, so I'm not sure how it is supposed to be done. I've pretty much always just copied the necessary data from a node, deleted it, created a new instance, and passed the data to the new instance.

How are you re-parenting the node? Did you change the node's owner to the new parent? I think a node's owner is in charge of making sure the node's functions are called correctly.

@TwistedTwigleg said: I haven't really had to re-parent nodes before, so I'm not sure how it is supposed to be done. I've pretty much always just copied the necessary data from a node, deleted it, created a new instance, and passed the data to the new instance.

How are you re-parenting the node? Did you change the node's owner to the new parent? I think a node's owner is in charge of making sure the node's functions are called correctly.

Ya that's how I'm doing it now too, I made c# objects that hold mob and map information, save to file or copy etc.

Also yes to setting owners. I did a lot of duckduckgo searches before I ended up here :P, two days trying to figure it out.

I'm moving ahead with the copy method for now, I don't want to slow down, but I would like to figure this out still.

Hmm, I'm not totally sure then. If I get the time, I'll see if I can make a quick test project.

I'll keep my eyes open and if I stumble across a solution, I'll post it here.

3 years later